Skip to content

Commit

Permalink
Merge pull request #97 from cloudblue/fix/LITE-25903
Browse files Browse the repository at this point in the history
LITE-25903 `cqrs_sync` is more DB failure tolerant
  • Loading branch information
maxipavlovic authored Nov 29, 2022
2 parents e4305c4 + e65eed1 commit 21e4df1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dj_cqrs/management/commands/cqrs_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from django.core.exceptions import FieldError
from django.core.management.base import BaseCommand, CommandError
from django.db import close_old_connections

import ujson

Expand Down Expand Up @@ -69,6 +70,7 @@ def handle(self, *args, **options):
for qs_ in batch_qs(model.relate_cqrs_serialization(qs), batch_size=batch_size):
ts = time.time()
cs = counter

for instance in qs_:
counter += 1
try:
Expand All @@ -78,6 +80,7 @@ def handle(self, *args, **options):
print('\nSync record failed for pk={0}: {1}: {2}'.format(
instance.pk, type(e).__name__, str(e),
))
close_old_connections()

if progress:
rate = (counter - cs) / (time.time() - ts)
Expand Down

0 comments on commit 21e4df1

Please sign in to comment.