Skip to content

Commit ea1d6f0

Browse files
committed
docs(run-engine): correct the reasoning on the acknowledged-run guard
The guard that stops a returned message being written back when its payload is gone was described as cleaning up an orphaned list entry. It is load-bearing: an acknowledgement landing between the candidate read and the script leaves a claimable worker queue entry whose run has already completed, and without the guard the sweep would put that completed run back on the pending queue. Also aligns two test doubles with the renamed result field.
1 parent b717937 commit ea1d6f0

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

apps/webapp/test/pauseSweepWiring.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ vi.mock("~/v3/runQueue.server", () => ({
2424
}),
2525
returnUnclaimedMessagesToQueue: vi.fn(async () => ({
2626
returned: 0,
27-
skipped: 0,
27+
skippedLastPass: 0,
2828
errors: 0,
2929
passes: 1,
3030
})),

apps/webapp/test/sweepUnclaimedRuns.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("sweepUnclaimedRuns", () => {
2424

2525
returnUnclaimedMessagesToQueue.mockResolvedValueOnce({
2626
returned: 2,
27-
skipped: 0,
27+
skippedLastPass: 0,
2828
errors: 0,
2929
passes: 1,
3030
});

internal-packages/run-engine/src/run-queue/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4846,7 +4846,8 @@ if claimed == 0 then
48464846
return 0
48474847
end
48484848
4849-
-- An orphaned list entry (payload already acknowledged): the LREM above cleaned it up.
4849+
-- Acknowledged between the candidate read and this script. The LREM above removed the
4850+
-- stale entry; the completed run must not be written back onto the queue.
48504851
if redis.call('EXISTS', messageKey) == 0 then
48514852
return 0
48524853
end
@@ -4927,7 +4928,8 @@ if claimed == 0 then
49274928
return 0
49284929
end
49294930
4930-
-- An orphaned list entry (payload already acknowledged): the LREM above cleaned it up.
4931+
-- Acknowledged between the candidate read and this script. The LREM above removed the
4932+
-- stale entry; the completed run must not be written back onto the queue.
49314933
if redis.call('EXISTS', messageKey) == 0 then
49324934
return 0
49334935
end

0 commit comments

Comments
 (0)