Skip to content

Commit bd99d6c

Browse files
fix(table): SQL cancellation guard allows worker to claim a null-execId cell
The dispatcher's pre-batch `pending` stamp leaves executionId unset so any cell-task that wins the cascade lock can claim the cell. The cancellation- guard SQL clause was rejecting these claims because it tested `executions->gid IS NULL` (whole exec missing) but the pre-stamp leaves the exec present with executionId=null. Add a third carve-out: `executions->gid->>'executionId' IS NULL`. Now the guard reads "write allowed if no exec exists, OR no executionId is set yet, OR the executionId matches ours." Symptom: every cell-task's first markWorkflowGroupPickedUp call would log "SQL guard saw cancelled" and skip, leaving cells stuck at the dispatcher's pending stamp.
1 parent 8fa3568 commit bd99d6c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

apps/sim/lib/table/service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,10 +1722,12 @@ export async function updateRow(
17221722
// (NULL) cleanly evaluates as "different" rather than NULL-poisoning.
17231723
sql`(executions->${guard.groupId}->>'status' IS DISTINCT FROM 'cancelled' OR executions->${guard.groupId}->>'executionId' IS DISTINCT FROM ${guard.executionId})`,
17241724
// Reject writes from a stale worker — the cell's active run has moved
1725-
// on. `OR exec IS NULL` lets the worker land its first `running`
1726-
// stamp on a row that has no prior exec record (initial stamp from
1727-
// the scheduler may not have committed yet).
1728-
sql`(executions->${guard.groupId} IS NULL OR executions->${guard.groupId}->>'executionId' = ${guard.executionId})`
1725+
// on. Two carve-outs let a fresh worker land its first stamp:
1726+
// - `exec IS NULL`: no prior exec at all.
1727+
// - `executionId IS NULL`: dispatcher's pre-batch `pending` stamp
1728+
// leaves the executionId unset so any cell-task that wins the
1729+
// cascade lock can claim the cell.
1730+
sql`(executions->${guard.groupId} IS NULL OR executions->${guard.groupId}->>'executionId' IS NULL OR executions->${guard.groupId}->>'executionId' = ${guard.executionId})`
17291731
)
17301732
: eq(userTableRows.id, data.rowId)
17311733

0 commit comments

Comments
 (0)