'ErrorLogPartition matching query does not exist' errors after upgrading 4.1.3 to 4.1.4
After upgrading from 4.1.3 to 4.1.4, I see errors similar to the following thrown every so often - it happens each time certain watch folders are checked for new documents:
[2021-12-31 13:06:41,540: ERROR/ForkPoolWorker-7] Task mayan.apps.sources.tasks.task_source_process_document[33a5a478-8ebc-40b7-a0a8-85a7bc8ec247] raised unexpected: DoesNotExist('ErrorLogPartition matching query does not exist.')
Traceback (most recent call last):
File "/opt/mayan-edms/lib/python3.7/site-packages/celery/app/trace.py", line 450, in trace_task
R = retval = fun(*args, **kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/celery/app/trace.py", line 731, in __protected_call__
return self.run(*args, **kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/tasks.py", line 53, in task_source_process_document
source.error_log.all().delete()
File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/logging/classes.py", line 47, in method_instance_logs
model_instance=self
File "/opt/mayan-edms/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/django/db/models/query.py", line 408, in get
self.model._meta.object_name
mayan.apps.logging.models.ErrorLogPartition.DoesNotExist: ErrorLogPartition matching query does not exist.
After a bit of debugging, it seems that there is no error log partition in the database for the watch folder sources in question. If I try to view the watch folder errors through the admin interface, it displays an error.
I can fix this by creating the missing error log partitions in the database manually, for example:
INSERT INTO logging_errorlogpartition (name, error_log_id) VALUES ('sources.Source.NNNN', 1);
I think in 4.1.4 the error log partition might be created when the watch folder source is created, so I thought a more 'production-ready' way to fix the issue would be to delete and re-create my sources. However, without the above manual database fix, I can't delete the existing sources because an error is thrown regarding the missing error log partition prior to deletion!