fix: fall back when Redis has no BLMOVE instead of crash-looping - #21
Merged
Conversation
BLMOVE needs Redis >= 6.2. Every GPU worker container in production is still on
Redis 6.0.16, and 1.0.17 (which introduced the BLMOVE claim) calls it
unconditionally. Upgrading a worker onto that Redis produces:
ERROR - Worker 0 crashed with error: unknown command `BLMOVE`, with args
beginning with: `ml_tasks`, `inflight:18187a468ab3:0`, `LEFT`, ...
about thirty times a second, forever. Reproduced on a live flux-klein box: the
worker never registered, the queue never drained, and nothing looked wrong from
outside -- `ps` showed modelq running and burning CPU while every request came
back "queued" with an ever-growing ETA. Nothing in production has hit this yet
only because every deployed container still runs an older ModelQ; requirements
files already pin 1.0.17, so the next rebuild would have.
Probe BLMOVE once, cache the answer, and on "unknown command" claim tasks with
an atomic Lua LPOP+RPUSH polled on a short interval instead. Both properties the
BLMOVE claim exists for are preserved: the task is never absent from both lists,
and the queue stays FIFO. Only the blocking is emulated.
BRPOPLPUSH is deliberately not used as the fallback. It is the obvious Redis 6.0
substitute and it is atomic, but it pops the tail -- against an rpush producer
that silently turns the queue LIFO and starves the oldest request.
Only "unknown command" disables BLMOVE; any other ResponseError (LOADING, etc.)
leaves a capable server on the fast path.
tests/test_blmove_fallback.py covers claim, atomicity, FIFO order, empty-queue
timeout, probe-once, the modern-Redis control case, and the unrelated-error
case. Mutation-tested: forcing _blmove_supported() to True turns five of them
red with the exact production error. Test extra bumped to fakeredis[lua].
The Redis 6.0 fallback claims tasks with an atomic Lua LPOP+RPUSH. Without the lua extra, fakeredis answers EVALSHA with 'unknown command' and the fallback tests fail for a reason that has nothing to do with the code under test.
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.
The failure
BLMOVEneeds Redis ≥ 6.2. Every GPU worker container in production is still on Redis 6.0.16, and 1.0.17 — which introduced the BLMOVE-based claim — calls it unconditionally.Reproduced on a live flux-klein box while upgrading it:
…repeating roughly thirty times a second, forever. The worker never registered,
ml_tasksnever drained, and nothing looked wrong from outside —psshowedmodelqrunning and burning CPU, while every request came back"status": "queued"with an ETA climbing 30s at a time.Nothing in production has hit this yet only because every deployed container still runs an older ModelQ (0.1.21 / 1.0.9 / 1.0.10 / 1.0.14 across the boxes I checked). Worker
requirements.txtfiles already pinmodelq==1.0.17, so the next image rebuild would have.The fix
Probe
BLMOVEonce, cache the answer, and onunknown commandclaim tasks with an atomic LuaLPOP+RPUSHpolled on a short interval.Both properties the BLMOVE claim exists for are preserved:
rpushproducer.Only the blocking is emulated.
BRPOPLPUSHis deliberately not the fallback. It is the obvious Redis 6.0 substitute and it is atomic — but it pops the tail, which against anrpushproducer silently turns the queue LIFO and starves the oldest request.Only
unknown commanddisables BLMOVE. Any otherResponseError(LOADING, etc.) leaves a capable server on the fast path.Tests
tests/test_blmove_fallback.py— claim, atomicity, FIFO order, empty-queue timeout, probe-once (the crash loop was 30 exceptions/second), the modern-Redis control case, and the unrelated-error case.Mutation-tested: forcing
_blmove_supported()to returnTrueturns five of them red with the exact productionResponseError.Test extra bumped to
fakeredis[lua]so the Lua path is actually exercised.Full suite: 114 passed.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.