Retry indexation if an operationalerror is encountered.
This commit is contained in:
@@ -2,6 +2,8 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from django.db import OperationalError
|
||||||
|
|
||||||
from mayan.celery import app
|
from mayan.celery import app
|
||||||
from documents.models import Document
|
from documents.models import Document
|
||||||
from lock_manager import Lock, LockError
|
from lock_manager import Lock, LockError
|
||||||
@@ -46,7 +48,14 @@ def task_index_document(self, document_id):
|
|||||||
# Document was deleted before we could execute, abort about updating
|
# Document was deleted before we could execute, abort about updating
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
IndexInstanceNode.objects.index_document(document)
|
IndexInstanceNode.objects.index_document(document)
|
||||||
|
except OperationalError as exception:
|
||||||
|
logger.warning('Operational error while trying to index document: %s; %s', document, exception)
|
||||||
|
lock.release()
|
||||||
|
raise self.retry(exc=exception)
|
||||||
|
else:
|
||||||
|
lock.release()
|
||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user