Commit 9acd68a4 authored by Michal Čihař's avatar Michal Čihař

Do not hold db lock while doing fulltext updates

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 158b9ed1
......@@ -19,6 +19,7 @@
#
from django.core.management.base import BaseCommand
from django.db import transaction
from weblate.trans.models import IndexUpdate, Unit
from weblate.trans.search import update_index
from optparse import make_option
......@@ -43,9 +44,11 @@ class Command(BaseCommand):
source_unit_ids = set()
# Grab all updates from the database
for update in IndexUpdate.objects.all()[:options['limit']].iterator():
indexupdates.add(update.pk)
unit_ids.add(update.unit_id)
with transaction.atomic():
updates = IndexUpdate.objects.all()
for update in updates[:options['limit']].iterator():
indexupdates.add(update.pk)
unit_ids.add(update.unit_id)
if update.source:
source_unit_ids.add(update.unit_id)
......@@ -62,4 +65,5 @@ class Command(BaseCommand):
update_index(units, source_units)
# Delete processed updates
IndexUpdate.objects.filter(id__in=indexupdates).delete()
with transaction.atomic():
IndexUpdate.objects.filter(id__in=indexupdates).delete()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment