IntegrityError when deleting a corpus with cached worker versions
Sentry Issue: ARKINDEX-BACKEND-C2
ForeignKeyViolation: update or delete on table "documents_corpus" violates foreign key constraint "dataimport_corpuswor_corpus_id_240ccc60_fk_documents" on table "dataimport_corpusworkerversion"
DETAIL: Key (id)=(392911aa-d2c2-49f7-a3c7-bc598876dd8c) is still referenced from table "dataimport_corpusworkerversion".
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
IntegrityError: update or delete on table "documents_corpus" violates foreign key constraint "dataimport_corpuswor_corpus_id_240ccc60_fk_documents" on table "dataimport_corpusworkerversion"
DETAIL: Key (id)=(392911aa-d2c2-49f7-a3c7-bc598876dd8c) is still referenced from table "dataimport_corpusworkerversion".
(6 additional frame(s) were not displayed)
...
File "django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
A QuerySet is missing on the corpora_delete
task to remove cached corpus worker versions.