Repository navigation
Description
Smaller correctness and usability gaps in the documentdb-local image and quickstart docs.
Items
- documentdb-local: failing --init-data-path script is reported as success (mongosh run without --file)
- Backends keep running after the client disconnects: client_connection_check_interval is never set
- documentdb-local: image does not EXPOSE the gateway port
- README quickstart: docker run has no volume (data lost on container removal) and no readiness guidance
1. documentdb-local: failing --init-data-path script is reported as success (mongosh run without --file)
A custom init script that throws or has a JS syntax error doesn't fail the container. run_mongosh_script runs mongosh --quiet --nodb <<'EOF' with no --file, so mongosh reads the heredoc in REPL mode and exits 0 after an uncaught error.
So if run_mongosh_script "$init_file" always takes the success branch (documentdb-local/scripts/init_documentdb_data.sh:249). The exit 1 path in emulator_entrypoint.sh:1472-1476 is never reached. Instead the container prints Custom data initialization completed., then === DocumentDB is ready ===, writes the success marker and goes healthy. Any partial write stays, and because of the attempt marker (#612) it is never retried. Compose depends_on: service_healthy also proceeds.
Repro: seed dir with db.getSiblingDB("seedq").t.insertOne({_id:1}); throw new Error("boom");, then run documentdb-local with --init-data-path /seed. Expected exit 1; actual: running, healthy.
Fix: use mongosh --quiet --nodb --file /dev/stdin <<'EOF' at init_documentdb_data.sh:133 (file mode propagates JS errors). Add an image test with a write-then-throw seed and a syntax-error seed asserting non-zero exit, no ready banner, not healthy. I couldn't find an existing test for a failing seed.
2. Backends keep running after the client disconnects: client_connection_check_interval is never set
If a client (or the gateway) goes away mid-query, PostgreSQL never notices, so the backend runs to completion and keeps its snapshot (backend_xmin) pinned. That blocks CREATE INDEX CONCURRENTLY and keeps pg_cron re-driving the index-build jobs.
On main nothing sets client_connection_check_interval (default 0 = off): not in the documentdb-local settings block (documentdb-local/scripts/documentdb-tools-lib.sh:262-282, render_documentdb_pg_conf), and not in the gateway's per-connection options (pg_documentdb_gw/documentdb_gateway_core/src/postgres/query_catalog.rs:662, which only sets search_path, statement_timeout and idle_in_transaction_session_timeout).
Note the gateway pool sessions are already bounded by statement_timeout (120s default, configuration/dynamic.rs:21) and idle-in-transaction (30s, dynamic.rs:23). The remaining gap is disconnect detection, plus no bounds at all for non-gateway sessions (psql/admin, cron workers), which get stock defaults of 0.
Suggested fix: add client_connection_check_interval = '10s' to the rendered documentdb-local block, and/or -c client_connection_check_interval=... to the gateway option string at query_catalog.rs:662. I'd leave statement_timeout unset globally, since long index builds run in cron/background sessions. Add a test in documentdb-local/scripts/documentdb_local_tests/ asserting the rendered block. This only helps while the backend is checking for interrupts; a backend stuck in a non-interruptible loop needs its own fix.
3. documentdb-local: image does not EXPOSE the gateway port
The documentdb-local image has a HEALTHCHECK on main, but it never declares EXPOSE, so docker image inspect shows no ExposedPorts. The default gateway port (10260) is only discoverable from the docs.
Code: packaging/gateway/docker/Dockerfile_documentdb_local
:133setsDOCUMENTDB_PORT="10260":239VOLUME,:266-267HEALTHCHECK,:268ENTRYPOINT; noEXPOSEanywhere
Impact is small. EXPOSE doesn't publish the port, but without it docker run -P, Compose/Kubernetes tooling and docker ps can't tell which port the image serves.
Suggested fix: add EXPOSE 10260 next to the HEALTHCHECK, with a comment that the port is configurable via DOCUMENTDB_PORT and EXPOSE only documents the default.
Related: #482 (added the healthcheck script and compose example).
4. README quickstart: docker run has no volume (data lost on container removal) and no readiness guidance
Two gaps in README Step 3 (README.md:69):
- No volume. The quickstart is
docker run -dt -p 10260:10260 --name documentdb-container documentdb --username ... --password .... The image declaresVOLUME ["$DATA_PATH"]withDATA_PATH=/data(packaging/gateway/docker/Dockerfile_documentdb_local:132,239), so the data lands in an anonymous volume. It survivesdocker restart, but afterdocker rm/docker runagain (or an image upgrade) the new container starts empty and the old data is orphaned. Nothing in the README says so. - No readiness note.
docker run -dtreturns before first-boot init (initdb, extension creation, user provisioning) finishes. The README goes straight to connecting. On slow filesystems (e.g. Docker Desktop) the first connection can time out, and there is no documented way to check. The entrypoint already prints=== DocumentDB is ready ===(documentdb-local/scripts/emulator_entrypoint.sh:1557).
Suggested fix, README only:
- Add
-v documentdb-data:/datato thedocker runline, plus one sentence: data lives in that volume and survives container recreation; remove the volume to start fresh. - Add a step:
docker logs -f documentdb-containerand wait for=== DocumentDB is ready ===. - Optionally point to
documentdb-local/examples/docker-compose, which already handles both (see Develop docker-compose examples #482).
Activity
guanzhousongmicrosoft commentedon Oct 5, 2026
Plan: items 1, 3 and 4 go in 1.0-RC2. Item 2 goes in 1.0.
guanzhousongmicrosoft commentedon Oct 6, 2026
1.0 blockers: items 1, 3 and 4. Item 1 is merged; 3 and 4 are in review. Item 2 doesn't block 1.0.
Merged PR 2342079: documentdb-local: require a password, reject an em…
documentdb-triage-tool commentedon Oct 28, 2026
👋 @guanzhousongmicrosoft — this issue has been assigned for 22 days with no activity. Is it still in progress? If you've made progress, please leave a quick update. Otherwise it'll be flagged for re-assignment at the next triage meeting.
documentdb-triage-tool commentedon Nov 11, 2026
👋 @guanzhousongmicrosoft — this issue has been assigned for 14 days with no activity. Is it still in progress? If you've made progress, please leave a quick update. Otherwise it'll be flagged for re-assignment at the next triage meeting.
guanzhousongmicrosoft commentedon Nov 23, 2026
Items 1 and 3 are fixed on main (ac6b21c, cf53d26). Item 2 (
client_connection_check_interval) and item 4 (the README volume and readiness note) are still open.