fix(service): hash-tag job cancellation keys for Redis Cluster - #7
Merged
TomasPalsson merged 1 commit intoSep 30, 2026
Merged
Conversation
Programmatic jobs failed with CROSSSLOT on cluster-mode Redis: the claim/commit/cancel scripts touch a job's marker, :result and :execution keys, which hashed to different slots. The worker failed the job but the API waited out JOB_TIMEOUT (~5 min) before returning a bare error. Wrap the per-job part of the key in a hash tag, and reconcile active jobs with one GET per job instead of a cross-slot MGET.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What breaks
On the sandbox (Redis in cluster mode), every programmatic run (
run_tools_with_bash, and any PTC job) fails. The worker errors right away with:The API never learns that the job failed, so it waits the full
JOB_TIMEOUT(about 5 min). Then it returns a bareCode execution failed.Plain/execruns likeecho histill work.Cause
The claim/commit/cancel Lua scripts in
job-cancellation.tstouch three keys for one job:<key>,<key>:resultand<key>:execution. The key had no hash tag, so on a cluster those keys hash to different slots.reconcile()also sent oneMGETacross many jobs, which crosses slots as well.Fix
reconcile()now does oneGETper job instead of a cross-slotMGET.Verification
bun test src/job-cancellation.test.tspasses 24/24.--cluster-enabled yes), the old code fails with the exact production CROSSSLOT error. The new code completes claim, commit and read.tsc --noEmitreports the same 7 existing errors before and after; none are in the changed files.job-cancellation-commit.test.ts, because it needs a localredis-server.Rollout
Deploy the API and the worker together, because the key names change.