packit-service icon indicating copy to clipboard operation
packit-service copied to clipboard

AttributeError: 'NoneType' object has no attribute 'sourceHeader'

Open sentry[bot] opened this issue 1 year ago • 2 comments

Sentry Issue: PCKT-002-PACKIT-SERVICE-78H

AttributeError: 'NoneType' object has no attribute 'sourceHeader'
  File "packit_service/worker/handlers/distgit.py", line 367, in run_for_target
    downstream_pr = self.sync_branch(
  File "packit_service/worker/handlers/distgit.py", line 244, in sync_branch
    downstream_pr = self.packit_api.sync_release(
  File "packit/api.py", line 1084, in sync_release
    spec_ver = self.up.get_specfile_version()
  File "packit/base_git.py", line 158, in get_specfile_version
    version = self.specfile.rpm_spec.sourceHeader[rpm.RPMTAG_VERSION]

sentry[bot] avatar Jul 10 '24 07:07 sentry[bot]

Note from @nforro : this looks not possible to reproduce so we can start with adding some debug info to know more.

lbarcziova avatar Jul 11 '24 10:07 lbarcziova

Since the issue used to happen when running Packit integration tests, I tried running the test suite locally in a container in a loop, as well as running the full test plan and packit-integration test plan from specfile with tmt in a VM a number of times, but the issue never appeared.

I've added some debugging messages to specfile and deployed it to both stage and prod, so hopefully the next time this happens we will have more info. Though I'm still puzzled how this can happen, rpm_spec should never be None, not without SpecfileException being raised first.

nforro avatar Jul 17 '24 08:07 nforro

Closing it because it does not happened again (after printing debug informations).

majamassarini avatar Aug 26 '24 09:08 majamassarini

It happened again https://artifacts.dev.testing-farm.io/b4f0a047-68b6-4538-a0d9-ee6ffeb5f87b/

majamassarini avatar Aug 28 '24 11:08 majamassarini

Sentry Issue: PCKT-002-PACKIT-SERVICE-8CZ

sentry[bot] avatar Sep 04 '24 09:09 sentry[bot]

Sentry Issue: PCKT-002-PACKIT-SERVICE-8CZ

I was finally able to obtain useful info from the logs and even reproduce the problem locally, however in order to trigger it the time between setting spec to None and creating a "new" Specfile instance must be very short, otherwise everything works properly:

>>> from specfile import Specfile
>>> spec = Specfile("test.spec")
>>> spec.rpm_spec
<rpm.spec object at 0x7f6d99733830>
>>> spec = None
>>> spec = Specfile("test.spec")
>>> spec.rpm_spec
>>> 

There is something weird going on, it almost looks like if the old Specfile instance is not garbage-collected quickly enough it is reused instead of creating a new instance. But let me investigate further.

nforro avatar Sep 04 '24 15:09 nforro

it almost looks like if the old Specfile instance is not garbage-collected quickly enough it is reused instead of creating a new instance

The instance is not reused, a new one is created, but the id of the old one is reused. And that's a problem because of the context switch detection implementation that relies on id.

nforro avatar Sep 04 '24 17:09 nforro