Repository navigation
test(tier1): the per-file drop keeps each model's indexes - #3717
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015AKgpQtAEnhB56gowm8yYg
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015AKgpQtAEnhB56gowm8yYg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015AKgpQtAEnhB56gowm8yYg
…Index Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015AKgpQtAEnhB56gowm8yYg
lilyshen0722
left a comment
There was a problem hiding this comment.
One review round, author's subagent (Haiku, effort medium), four passes. Test infra only.
Covered: the new test's reconnect, env restore in every tier, and that allSettled doesn't hide the guarded case, since the test still fails if the index is missing. Both Tier 1 shards pass at this head, which is the evidence over the whole service directory.
The reviewer didn't reproduce the author's 40-of-40 and 3-of-3 runs. Their own harness, on another mongod with a different order, lost the index 0 of 100 times. The PR body says so.
Not fixed: allSettled drops rejection reasons, so a future conflict stays as quiet as it is in autoIndex. _connectionString is a private mongoose field. User's index conflict is on the board.
GATE: PASS
|
@coderabbitai review |
Action not completed
|
stalledConnectMcpSeen.test.jsejected #3496 from the queue (run 42386512527). Five tests failed, and each one leans on the unique index onStalledConnectEpisode: a second scan posted again, and two episodes existed where one should. The same code passed one slot later. The log shows the file failed once; the second listing is jest's summary.Cause: in Tier 1,
setupMongoDbconnects, then drops the shared database. Connecting starts each loaded model's index build, anddropDatabaseremoves any index that has already finished. Mongoose doesn't rebuild it, so that file runs with no unique index. Which index goes depends on timing, so any Tier 1 test that relies on one can flake this way.Fix: wait for the loaded models' index builds, drop, then build their indexes again. The setup change is Tier 1 only. Memory-server runs gain the one new test, which does a drop and rebuild of its own. A model first loaded after setup still builds its own.
Proof
tier1-setup-keeps-indexes.test.jsruns in every tier, needs no Tier 1 job, and is deterministic. It sets up a second time after the model's build has finished, which is the case where the build beats the drop. On main'stestUtils.jsit failed 3 of 3 runs; with this change it passes. It names the(installationId, tokenIssuedAt)index.setupMongoDbwithINTEGRATION_TEST=trueon mongod 7.0.14, one model with a unique index: missing 40 of 40 on main, 0 of 40 with this change.A real conflict this turned up:
Userdeclares a uniqueusernameindex and a collated one, and both get the nameusername_1. Mongo refuses the second. autoIndex swallows that, so an awaitedPromise.allfailed the whole Tier 1 job on an earlier head of this PR. The setup usesallSettled, which keeps autoIndex's behaviour. The schema is left alone here because changing it builds a new index on the realuserscollection, so it needs its own change.Cost: each Tier 1 file builds its models' indexes once more, on empty collections. Compare the job's time here against main.
🤖 Generated with Claude Code
https://claude.ai/code/session_015AKgpQtAEnhB56gowm8yYg