AttributeError: 'NoneType' object has no attribute 'sourceHeader'
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]
Note from @nforro : this looks not possible to reproduce so we can start with adding some debug info to know more.
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.
Closing it because it does not happened again (after printing debug informations).
It happened again https://artifacts.dev.testing-farm.io/b4f0a047-68b6-4538-a0d9-ee6ffeb5f87b/
Sentry Issue: PCKT-002-PACKIT-SERVICE-8CZ
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.
it almost looks like if the old
Specfileinstance 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.