Skip to content

Commit 38fae69

Browse files
triklozoidfarioas
andauthored
fix: PLT-956: Fix deadlock on bulk tasks update (#8958)
Co-authored-by: farioas <farioas@users.noreply.github.com>
1 parent 8e90195 commit 38fae69

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

label_studio/tasks/functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ def update_tasks_counters(queryset, from_scratch=True):
198198
)
199199

200200
# filter our tasks with 0 annotations and 0 predictions and update them with 0
201-
queryset.filter(annotations__isnull=True, predictions__isnull=True).update(
201+
# order_by('id') ensures consistent row locking order to prevent deadlocks
202+
queryset.filter(annotations__isnull=True, predictions__isnull=True).order_by('id').update(
202203
total_annotations=0, cancelled_annotations=0, total_predictions=0
203204
)
204205

0 commit comments

Comments
 (0)