Issue #4653
Updated by bmbouter over 5 years ago
When orphan cleanup goes to run it can run into problems if there are model types that refer to each other for example both AnsibleRole and AnsibleRoleVersion relate to each other and are both content types. They could have been modeled differently, but they are modeled this way for now. This means that because you can't delete an AnsibleRole that has AnsibleRoleVersions due to cascade.PROTECTED if orphan cleanup tries to delete AnsibleRole it will fail. For example this is a traceback showing this problem (provided by @rochacbruno) <pre> [root@fedora-29-pulp-3 ~]# systemctl status pulp-resource-manager --no-pager --full ● pulp-resource-manager.service - Pulp Resource Manager Loaded: loaded (/etc/systemd/system/pulp-resource-manager.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2019-04-08 15:26:09 -03; 29min ago Main PID: 13446 (rq) Tasks: 1 (limit: 2351) Memory: 57.7M CGroup: /system.slice/pulp-resource-manager.service └─13446 /usr/local/lib/pulp/bin/python3 /usr/local/lib/pulp/bin/rq worker -w pulpcore.tasking.worker.PulpWorker -n resource-manager@%h --pid=/var/run/pulp-resource-manager/resource-manager.pid Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/db/models/deletion.py", line 224, in collect Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: field.remote_field.on_delete(self, field, sub_objs, self.using) Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/db/models/deletion.py", line 16, in CASCADE Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: source_attr=field.name, nullable=field.null) Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/db/models/deletion.py", line 224, in collect Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: field.remote_field.on_delete(self, field, sub_objs, self.using) Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/db/models/deletion.py", line 27, in PROTECT Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: sub_objs Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'AnsibleRole' because they are referenced through a protected foreign key: 'AnsibleRoleVersion.role'", <QuerySet [<AnsibleRoleVersion: pk=dcf32b6a-b524-4941-ae8f-54b6f1e90023>, <AnsibleRoleVersion: pk=057dd842-12b2-43e8-98c0-c75246073ed3>, <AnsibleRoleVersion: pk=f6e96f34-431d-43b9-8534-4854bd1196c1>, <AnsibleRoleVersion: pk=66adbbbb-edca-44e9-ba18-e8359dfce98d>, <AnsibleRoleVersion: pk=f98ac996-c60e-415b-affc-f5a8a5cd02e7>]>) Apr 08 15:28:36 fedora-29-pulp-3 rq[13446]: pulp: rq.worker:WARNING: Moving job to 'failed' queue </pre>