From 004b0c75d788e0c35c1ba46360fd4a59e4df94a6 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 11 Jul 2015 17:00:13 -0400 Subject: [PATCH] Retry indexation if an operationalerror is encountered. --- mayan/apps/document_indexing/tasks.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mayan/apps/document_indexing/tasks.py b/mayan/apps/document_indexing/tasks.py index e2850a953e..276b448ba4 100644 --- a/mayan/apps/document_indexing/tasks.py +++ b/mayan/apps/document_indexing/tasks.py @@ -2,6 +2,8 @@ from __future__ import unicode_literals import logging +from django.db import OperationalError + from mayan.celery import app from documents.models import Document 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 pass else: - IndexInstanceNode.objects.index_document(document) + try: + 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: lock.release() finally: