Issue #1243: fix: create person_identifier_idx whether or not the MongoDB instance is seeded - #1307
Open
dereck-symmetry wants to merge 1 commit into
Open
dereck-symmetry wants to merge 1 commit into
dereck-symmetry wants to merge 1 commit into
Conversation
…goDB instance is seeded The entrypoint exited before the index step when SEED_DATA_KEY was unset, so an unseeded instance came up with no index (and no collection). Seeding stays conditional; index creation now always runs, still after the import when there is one, because mongoimport --drop drops the collection's indexes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Description of Change
Problem.
person_identifier_idx, the index behind the Query Cache's identity filter (query(),update(),save()), was created only as a side effect of seeding.projects/mongodb/entrypoint.shdidexit 0whenSEED_DATA_KEYwas unset, before the index step, so an unseeded instance came up with no index at all. This is case 2 in #1243.Solution. The seeding block becomes
if/elseinstead of an earlyexit 0. Seeding is still conditional onSEED_DATA_KEY. Index creation now always runs, and still after the import when there is one, becausemongoimport --dropdrops the collection along with its indexes.git diff -wshows the real change is 3 lines plus a comment; the rest is re-indentation into theelse. Theentrypoint.shrow inprojects/mongodb/README.mdnow mentions the index.When the collection doesn't exist yet,
createIndexcreates it, so an unseeded instance comes up with an emptypersoncollection that already has the index.Why this approach (option 1 in the issue) and not a Query Cache startup
create_index(option 2). Deployed MongoDB has no persistent storage: the EFSMountPointsincloudformation/mongodb-taskdef-includes.ymlare commented out. Every ECS task starts from an empty data dir and reruns the entrypoint, so on dev and demo the entrypoint alone covers every case, including an unseeded one. The startup ensure would add a MongoDB dependency to the Query Cache's startup path (it has no lifespan today) and would need a failure-mode decision. We're leaving that out until it's actually needed.Limitation. This is why the PR says
Refs, notCloses. The issue's first acceptance criterion says an instance created before #1242 should end up with the index. Docker runs/docker-entrypoint-initdb.d/only on an empty data dir, so a local named volume that already exists (for examplemongo_dataindevelopment/advisor-demo-1org) won't get the index from this change. The fix there isdocker compose down -v. Case 3 in the issue (a MongoDB not built fromprojects/mongodb) is also not covered. Both would need option 2. The second criterion (existence doesn't depend onSEED_DATA_KEY) is met.How reviewers should test it.
Repeat with
-e SEED_DATA_KEY=advisor-demo-org1to check the seeded path is unchanged: 4 docs plus the index.Related Issues
Refs #1243
Refs #1131
Type of Change
Project Area(s) Affected
Checklist
Testing
A fresh container each time, built from
projects/mongodb, withMONGO_HOST=mongodb-org1(a service name that doesn't resolve, the same shape as ECS):mainSEED_DATA_KEYunset[_id_, person_identifier_idx]SEED_DATA_KEY=advisor-demo-org1[_id_, person_identifier_idx][_id_, person_identifier_idx]SEED_DATA_KEY=advisor-demo-org3[_id_, person_identifier_idx]No automated test is added. The entrypoint is a shell init script that only runs inside the MongoDB image, and the one suite that checks the index (
integration_tests/test_01_mongodb.py) is local-only and not run by CI. It asserts the index on the seeded path, which this change doesn't alter.pre-commit run --filespassed on both changed files, andbash -npassed on the script.Additional Notes
mongodb.ymlwatchesprojects/mongodb/**. Dev MongoDB keeps no data between restarts, so each org reseeds, the same as it did when Issue #1304: fix: create the Query Cache index against the init-time mongod on localhost #1305 merged.projects/mongodb/.🤖 Generated with Claude Code