Skip to content

[documentdb-local] Lifecycle, upgrade and settings gaps in the container image #773

Open

Description

@guanzhousongmicrosoft

These lifecycle, upgrade and settings gaps in the documentdb-local image were found by running the containers through restart, kill, recreate and image-upgrade scenarios.

Tested on release/1.0-RC2-v2 @ 40f86c0. The images (pg17, pg18) were built from packaging/gateway/docker/Dockerfile_documentdb_local the way CI builds them. Older volumes came from the published 1.0-rc1 and latest (0.117.0) images.

Related: #758 (secure defaults), #759 (init and quickstart), #688 (E2E coverage), #752 (admin can't create users).

Items

  • A bind-mount volume is wedged for good if the first boot is interrupted
  • Boot failures exit without stopping PostgreSQL, so every failed boot leaves crash recovery for the next one
  • A newer image never runs ALTER EXTENSION ... UPDATE on an existing volume
  • A PG major mismatch between volume and image gives only "start_oss_server.sh failed"
  • A changed --password on an existing volume is silently ignored
  • --log-level and --enable-telemetry do nothing
  • Init data: a typo'd path is silent, scripts run on already-used volumes, and a failed seed is skipped forever
  • Input validation is late or missing
  • Log noise

1. Interrupted first boot on a bind mount

docker kill during the first-boot CREATE EXTENSION on an empty bind mount, then start again:

  • The second boot refuses because of the stale postmaster.pid. That message is good: it names DOCUMENTDB_FORCE_REMOVE_STALE_POSTMASTER_PID=true.
  • With the override set, every boot fails with schema "documentdb_api" does not exist / "could not install the getParameter rejection stub".

PG_VERSION exists, so start_oss_server.sh skips setup, and nothing ever creates the extensions. Named volumes avoid this because of the baked template.

Expected: detect the half-initialized cluster and finish setup.

2. Failed boots skip PG shutdown

Several error paths in emulator_entrypoint.sh call exit instead of cleanup, so PostgreSQL is SIGKILLed. These include:

  • the EnforceTls write
  • PG never ready for admin creation
  • admin creation failure
  • the gateway readiness timeout
  • any command failure after utils.sh installs its ERR trap

Example: a bad custom cert. The container exits after 65 s with "Gateway failed to start within 60 seconds" and no "Stopping PostgreSQL" line. The next boot logs removing /data/postmaster.pid ... left by an unclean stop and PG runs crash recovery. With --restart unless-stopped this loops every ~63 s.

The cert error itself should also be reported immediately: today the entrypoint waits the full 60 s polling a port the dead gateway will never open.

3. No extension update on image upgrade

We started a volume created by latest (0.117.0, PG17) under the RC2 PG17 image:

Neither emulator_entrypoint.sh nor start_oss_server.sh runs ALTER EXTENSION documentdb_core/documentdb/documentdb_extended_rum UPDATE.

4. PG major mismatch

A PG17 image on a PG18 volume (or the reverse, e.g. when latest moves) prints only start_oss_server.sh failed (status 1). The real reason ("database files are incompatible with server") is only in pglog.log inside the volume.

Expected: compare PG_VERSION with the server major before starting, and print which tag to use.

5. Password change ignored

Restarting with a new --password on an existing volume prints only Role u already exists.. The old password keeps working and the new one fails.

Combined with first-time INIT_DATA=true, the container exits 1 after 88 s with "did not become ready within 60 seconds", although the real cause is an auth failure.

Expected: update the password, or warn loudly that it was ignored.

6. No-op flags

--log-level and --enable-telemetry are validated and listed in --help, but nothing reads LOG_LEVEL or ENABLE_TELEMETRY. --log-level trace and --log-level quiet give identical gateway logs. The gateway reads DOCUMENTDB_LOG_LEVEL/RUST_LOG.

7. Init data

  • A nonexistent --init-data-path prints "No initialization data loaded." and continues.
  • The docs say init data applies to fresh volumes, but scripts mounted on an already-used volume with no marker run on that boot.
  • After a failed custom seed, later boots skip it forever and the container reports healthy without the data. It now warns, but the healthcheck still passes.

8. Validation

Input Behaviour
Gateway port 0 or 65536 Fails only after 63-65 s. --pg-port 70000 is caught in 3 s
--username --password Sets the username to "--password"
Username with a space Accepted
DOCUMENTDB_PORT == POSTGRESQL_PORT Fails fast, but as a Rust unwrap() panic
--create-user false --init-data true Auth failure after 89 s
Non-empty bind dir without PG_VERSION Message tells container users to pass a -c flag they can't pass
Data path with spaces Fails: "pg_ctl: too many command-line arguments"
--user 1001:1001 emulator_entrypoint.sh: Permission denied

9. Logs

  • Every gateway line appears twice in docker logs: raw, and again with [GATEWAY-FILE].
  • The [GATEWAY] prefix the banner promises doesn't exist.
  • Readiness and healthcheck probes log gateway ERROR ... Connection closed on every probe.
  • FATAL: database "documentdb" does not exist repeats.
  • The TLS state-dir WARN appears on every boot.

Activity

  1. added
    documentdb-local
    documentdb-1.0
    on Oct 5, 2026
  2. added this to the 1.0 milestone on Oct 6, 2026
  3. added
    1.0-blocker
    on Oct 6, 2026
  4. guanzhousongmicrosoft commented on Oct 6, 2026

    @guanzhousongmicrosoft
    MemberAuthor

    1.0 blocker: item 3 (a newer image never updates the volume's extensions). The fix is in review. The other items don't block 1.0.

  5. guanzhousongmicrosoft commented on Nov 23, 2026

    @guanzhousongmicrosoft
    MemberAuthor

    On main: item 3 (extensions are updated when the image is upgraded, 53e5456) and the --log-level part of item 6 (e91dd04). #833 makes documentdb-local refuse a data path with whitespace or glob characters with a clear error instead of failing in pg_ctl. The other items are still open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.0-blockerbugdocumentdb-1.0documentdb-local

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions