Repository navigation
fix: Skip sample data init on restart if data already exists (#479) - #498
Ritvik-Jayaswal wants to merge 4 commits into
Conversation
guanzhousongmicrosoft
left a comment
There was a problem hiding this comment.
I would prefer a marker file indicating initialization status
Address PR review feedback: - Replace mongosh-based database check with a simple marker file (.sample_data_initialized / .custom_data_initialized) written to DATA_PATH after successful init. On restart the marker file is detected and initialization is skipped. (visridha, guanzhousongmicrosoft) - Flip sample data from opt-out (--skip-init-data) to opt-in (--load-sample-data / LOAD_SAMPLE_DATA env var). Sample data is now disabled by default. (guanzhousongmicrosoft, xgerman) - Also add marker file for custom data (--init-data-path) to prevent re-initialization on restart.
|
In the custom init failure path, we now warn and continue, but the marker file is only written on success. With a persisted data dir, that means the same failing custom init will be retried on every restart and keep warning forever. Should this either still fail fast, or persist some state so restart behavior converges? |
Fixed: Now writes marker file even on failure, so restart converges. |
The previous nc-based TCP connection caused the TLS-enabled gateway to crash with an SSLError when it received a raw (non-TLS) connection. Instead, inspect /proc/net/tcp6 for a LISTEN socket (state 0A) on the gateway port, which is zero-impact and avoids connecting to the port.
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (build); effort from diff stats (81+61 LOC, 1 files); LLM: Fixes a container crash on restart due to duplicate _id errors when re-running sample data init against a persisted data path. If a label is wrong, remove it manually and ping |
|
Stale PR. |
Fixes #479
Problem
When the DocumentDB-local emulator container is restarted with a persisted
--data-path, the entrypoint always re-runs sample data initialization. Since the sample JS files useinsertManywith hardcoded_idvalues, this fails with aDuplicateIDerror, crashing the container on restart.Fix
check_database_has_datahelper that usesmongoshto check if a database already contains data.sampledbalready has data — if so, skip initialization with a log message.--init-data-path), changed the failure from a hardexit 1to a warning + continue, since custom scripts may also fail on restart if data already exists.The text: "Sample data already exists..." shows in the output to confirm this fix:
