Skip to content

Commit f726b1d

Browse files
Maffoochclaude
andcommitted
fix(sla): reset in-memory async_updating after dispatch
Before the pickle removal, the SLA recompute task received the SLA_Configuration / Product instances by reference (Celery's sync .apply() does not serialize). The inner update function set async_updating=False on those shared instances, so the dispatcher's local self.async_updating ended up False as well. After switching the dispatch to pass IDs and refetch in the task, the inner function only resets async_updating on its refetched copies. The dispatcher's in-memory self.async_updating stayed True, so a subsequent save() on the same instance triggered the lock-revert path at SLA_Configuration.save() line 1058 and overwrote the caller's field changes (e.g. enforce_critical) with the DB values. Manifested as test_sla_expiration_date_after_sla_not_enforced failing: sla_config.enforce_critical=False was reverted to True on save. Reset async_updating on the in-memory caller instances after dispatch returns to keep them consistent with the post-task DB state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 424f490 commit f726b1d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

dojo/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,10 @@ def save(self, *args, **kwargs):
10991099
list(products.values_list("id", flat=True)),
11001100
severities=severities,
11011101
)
1102+
# The async task refetches and resets async_updating on its own copy.
1103+
# Mirror that on this in-memory instance so a subsequent save() on the
1104+
# same instance does not trigger the lock-revert path at line 1058.
1105+
self.async_updating = False
11021106

11031107
def clean(self):
11041108
sla_days = [self.critical, self.high, self.medium, self.low]
@@ -1265,6 +1269,12 @@ def save(self, *args, **kwargs):
12651269
sla_config.id,
12661270
[self.id],
12671271
)
1272+
# The async task refetches and resets async_updating on its own copies.
1273+
# Mirror that on this in-memory product and the in-memory sla_config so a
1274+
# subsequent save() on either does not trigger their lock-revert paths.
1275+
self.async_updating = False
1276+
if sla_config:
1277+
sla_config.async_updating = False
12681278

12691279
def get_absolute_url(self):
12701280
return reverse("view_product", args=[str(self.id)])

0 commit comments

Comments
 (0)