Repository navigation
Show index-build progress while the run waits on the {cd,_id} index - #12
Merged
Merged
Conversation
The run builds a missing {cd:1,_id:1} index itself during mapping, but the
dashboard showed nothing during that wait (hours to days on large sources):
the run progress bar stays hidden until chunks exist, and index progress was
only polled after clicking "Build missing indexes".
- Track the collection mapping is blocked on (with its position in the map
pass) around ensureIndex itself; an in-progress build lists as present but
still blocks, so the hasRequiredIndex check is the wrong trigger.
- Parse $currentOp: prefer the IndexBuildsCoordinator op (it carries
progress) over the waiting client op, keep only {cd:1,_id:1} builds on the
source db, and report the step, because the percentage restarts per step:
scanning documents, sorting index keys (the builder reports "scanning
collection" without counters for 30-45% of the build after the scan
ends), writing index keys, applying writes made during the build.
- Sharded clusters: through mongos every shard reports its own builder with
per-shard counters; the slowest shard is reported with the number of
shards still building. Secondaries omit command.$db; matched through ns.
- Run $currentOp with readConcern local. The source client defaults to
majority, which $currentOp refuses; the error was swallowed, so server-side
progress never showed under the default config. Failures are now returned
as serverOpsError and shown in the UI.
- The Build missing indexes button joins builds already in flight instead of
reporting "all indexed" while one is running.
- Overview tab: a dedicated index bar (collection N of M, step N of 4,
percentage, wait time), polled with the 5s slow tick so it covers builds
the run starts itself and builds started by a dry run.
Tests:
- Unit (run in the CI unit job): the parser against real $currentOp
recordings from MongoDB 8.0 (replica-set primary and secondary, 2-shard
cluster via mongos), including whole-build replays; orchestrator index
logic against a fake MongoDB.
- Integration: the mapping-time state under the default readConcern
majority, the listed-but-building case, and the button path.
Hakandede
force-pushed
the
feat/index-build-progress
branch
from
October 22, 2026 22:14
ea3f4cf to
d2a1f6c
Compare
Deployments run MongoDB 8.0, so the integration job now uses the mongo:8.0 service image and is named accordingly. The full suite passes on MongoDB 8.0.34 with ClickHouse 26.8.34.13.
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
When
{cd:1,_id:1}is missing, the run builds it during mapping. On large sources that wait can take hours to days, and the dashboard showed nothing: the run progress bar stays hidden until chunks exist, and index progress was only polled after clicking "Build missing indexes".The Overview tab now shows an index bar while the run waits on an index:
When the index is ready the bar disappears and the normal run progress bar takes over. Guide step 2 lists the run's own builds too, not only button builds.
Behaviour
$currentOp(the builder thread'sprogress {done,total}andmsg); the client op waiting on the build has no counters and only shows when no builder is visible.command.$db; matched throughns.ensureIndexitself, not thehasRequiredIndexcheck: an in-progress build is listed as present but still blocks.Fixes found on the way
readConcern: majority, and$currentOprefuses anything butlocal; the error was swallowed. The query now pinslocal, and any failure is returned asserverOpsErrorand shown in the UI instead of "no builds".CI
mongo:8.0service image (renamed to Integration (MongoDB 8.0 + ClickHouse 26.8)), the MongoDB line deployments run. No ruleset requires the job by name.tests/unit(it only rantests/differential).Blast radius
mapCollection: only records state around the existingensureIndexcall (try/finally); no change to what it reads or writes./api/index-progress: addsauto,phases,serverOpsError;serverOpsentries gainphase,phaseLabel,done,total,shard,shards. Only the dashboard consumes it./control/build-indexes: response gainsinProgress.Tests
Tested against MongoDB 8.0.34 and ClickHouse 26.8.34.13.
tests/unitthere; it only rantests/differential):$currentOprecordings from MongoDB 8.0.34: replica-set primary, replica-set secondary, 2-shard cluster via mongos;ensureIndexfails.readConcern: majority, the listed-but-building case, and the button path.nsfallback, state not cleared, in-flight builds ignored, step not reported, no sorting step) each make tests fail.Run for real
Real migrator and dashboard on a dev VM, CPU-throttled MongoDB so builds are watchable:
serverOpsErrorat any sample.Not covered
inprogprivilege: unit-tested only (the bar shows the reason instead of a percentage).