Repository navigation
ruby / ci-queue: Recover queue initialization when the master exits - #103
Merged
Merged
Conversation
ckwarteng
marked this pull request as ready for review
October 9, 2026 23:15
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 8b3da9d. Configure here.
Replace the renewable initialization lease with two smaller pieces: - The setup marker expires after half of queue_init_timeout, so a waiting worker can take over when the elected master dies before publishing. - Publication (queue, chunk metadata, total, ready status) is one WATCH-guarded transaction, so if a slow master and its replacement both finish, only the first publishes and the other joins that queue. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ckwarteng
force-pushed
the
ckwarteng/recover-ci-queue-initialization
branch
from
October 10, 2026 01:00
9af9801 to
9d7fb11
Compare
ebarajas
approved these changes
Oct 13, 2026
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.

There’s a long-standing ci-queue bug that causes CI::Queue::Redis::LostMaster. If the initializer dies (example during spot terminations) before publishing the queue, its setup marker remains indefinitely, preventing surviving workers and retried jobs from taking over. This change simplifies the flow and makes initialization recoverable.
We also add some new queue initialization unit tests. The downside is that we make more redis requests than before (about 20 extra requests per second per waiting worker). This will well within how much we can support so I think the simplicity is worth it.
Written by AI
When the elected initializer dies before publishing the test queue, its
master-status=setupmarker previously remained indefinitely. Surviving workers and replacement jobs could not initialize the queue and failed withCI::Queue::Redis::LostMaster. In build 8569214, a spot termination during initialization left both surviving workers and the initializer's retry waiting on the abandoned marker.The setup marker now expires after half of
queue_init_timeout, and waiting workers attempt initialization again. AWATCH-guarded transaction publishes the queue, total, and ready status together, so the first initializer to publish wins. A slow initializer can overlap its replacement; each attempt gives its chunks unique IDs, keeping their metadata and dynamic timeouts separate.Chunk metadata is staged in batches of five, using at most 22 commands per transaction. Final publication uses six commands. This respects Sinatra's 25-command transaction limit. Metadata retains the existing Redis TTL, including unused chunks from an interrupted or superseded attempt.
Validation:
sinatra-collate-coveragewithNo Sinatra test coverage results were found: forced job selection included default-branch coverage reporting on feature branches, where coverage collection is disabled. All 100 Sinatra test workers passed in each build; these are successful test groups, not fully green builds.