Skip to content

Commit 2de0452

Browse files
committed
🐛(backend) fix race condition in reconciliation requests CSV import
The call to the background task is now wrapped in a on_commit to ensure that it isn't called before the save is finished, in order to avoid race condition issues.
1 parent 79e909c commit 2de0452

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to
1212
- ♿️(frontend) add contextual browser tab titles for docs routes #2120
1313
- ♿️(frontend) fix empty heading before section titles in HTML export #2125
1414

15+
### Fixed
16+
17+
- 🐛(backend) fix race condition in reconciliation requests CSV import #2153
18+
1519
## [v4.8.4] - 2026-03-25
1620

1721
### Added

src/backend/core/admin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"""Admin classes and registrations for core app."""
22

3+
from functools import partial
4+
35
from django.contrib import admin, messages
46
from django.contrib.auth import admin as auth_admin
7+
from django.db import transaction
58
from django.shortcuts import redirect
69
from django.utils.translation import gettext_lazy as _
710

@@ -108,7 +111,9 @@ def save_model(self, request, obj, form, change):
108111
super().save_model(request, obj, form, change)
109112

110113
if not change:
111-
user_reconciliation_csv_import_job.delay(obj.pk)
114+
transaction.on_commit(
115+
partial(user_reconciliation_csv_import_job.delay, obj.pk)
116+
)
112117
messages.success(request, _("Import job created and queued."))
113118
return redirect("..")
114119

0 commit comments

Comments
 (0)