Skip to content

Commit b315324

Browse files
fix(table): bulk clear honors in-flight execs under mode: 'incomplete'
The eager bulk clear for mode: 'incomplete' only skipped rows that were already fully filled, so two overlapping dispatches could race — dispatch B would nuke executions[gid] on a row dispatch A had just stamped 'queued', flickering the cell and potentially confusing the worker. Skip any row whose targeted group is currently queued/running/pending — an 'incomplete' run shouldn't touch what another dispatch is actively working on. The per-walk 'in-flight' eligibility skip already handles rows that flip in-flight between the clear and the cursor reaching them.
1 parent 6b30f14 commit b315324

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

apps/sim/lib/table/dispatcher.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ export async function bulkClearWorkflowGroupCells(input: {
8080
)
8181
const allFilled = filledChecks.reduce((acc, expr) => sql`${acc} AND ${expr}`)
8282
filters.push(sql`NOT (${allFilled})`)
83+
// Also skip rows where ANY targeted group has an in-flight exec from
84+
// another dispatch — clobbering its `executions[gid]` would race with
85+
// the in-flight worker. An `incomplete` run by definition shouldn't
86+
// touch rows another dispatch is actively working on.
87+
const inFlightChecks = groupIds.map(
88+
(gid) =>
89+
sql`${userTableRows.executions} -> ${gid}::text ->> 'status' IN ('queued', 'running', 'pending')`
90+
)
91+
const anyInFlight = inFlightChecks.reduce((acc, expr) => sql`${acc} OR ${expr}`)
92+
filters.push(sql`NOT (${anyInFlight})`)
8393
}
8494

8595
await db

0 commit comments

Comments
 (0)