Skip to content

Fix task_deindex_instance crash when object deleted before task runs#45

Open
pranithreddym wants to merge 1 commit into
mayan-edms:masterfrom
pranithreddym:fix/task-deindex-does-not-exist
Open

Fix task_deindex_instance crash when object deleted before task runs#45
pranithreddym wants to merge 1 commit into
mayan-edms:masterfrom
pranithreddym:fix/task-deindex-does-not-exist

Conversation

@pranithreddym
Copy link
Copy Markdown

When a document is deleted (e.g. emptied from Trash), Celery may not execute task_deindex_instance until after the DELETE has committed. The task called Model.objects.get(pk=object_id) without guarding for DoesNotExist, causing an unhandled exception and a CRITICAL traceback in the worker logs on every trash-empty operation.

task_index_instance already handles this case with a retry; for de-indexing a non-existent object, a retry makes no sense since there is nothing to de-index. The fix catches DoesNotExist, logs a WARNING, and returns cleanly.

Also adds a regression test:
test_task_deindex_instance_object_already_deleted

Fixes GitLab issue #1185.

When a document is deleted (e.g. emptied from Trash), Celery may not
execute task_deindex_instance until after the DELETE has committed.
The task called Model.objects.get(pk=object_id) without guarding for
DoesNotExist, causing an unhandled exception and a CRITICAL traceback
in the worker logs on every trash-empty operation.

task_index_instance already handles this case with a retry; for
de-indexing a non-existent object, a retry makes no sense since there
is nothing to de-index. The fix catches DoesNotExist, logs a WARNING,
and returns cleanly.

Also adds a regression test:
  test_task_deindex_instance_object_already_deleted

Fixes GitLab issue #1185.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant