fix: Multi process startup document modification executed multiple times (#2581)
This commit is contained in:
parent
be31989ab9
commit
000a3970e0
@ -12,15 +12,22 @@ from .listener_manage import *
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from ..db.sql_execute import update_execute
|
from ..db.sql_execute import update_execute
|
||||||
|
from common.lock.impl.file_lock import FileLock
|
||||||
|
|
||||||
|
lock = FileLock()
|
||||||
update_document_status_sql = """
|
update_document_status_sql = """
|
||||||
UPDATE "public"."document"
|
UPDATE "public"."document"
|
||||||
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
|
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
|
||||||
|
WHERE status ~ '1|0|4'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
# QuerySet(Document).filter(status__in=[Status.embedding, Status.queue_up]).update(**{'status': Status.error})
|
if lock.try_lock('event_init', 30 * 30):
|
||||||
QuerySet(Model).filter(status=setting.models.Status.DOWNLOAD).update(status=setting.models.Status.ERROR,
|
try:
|
||||||
meta={'message': _('The download process was interrupted, please try again')})
|
QuerySet(Model).filter(status=setting.models.Status.DOWNLOAD).update(status=setting.models.Status.ERROR,
|
||||||
update_execute(update_document_status_sql, [])
|
meta={'message': _(
|
||||||
|
'The download process was interrupted, please try again')})
|
||||||
|
update_execute(update_document_status_sql, [])
|
||||||
|
finally:
|
||||||
|
lock.un_lock('event_init')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user