Repository navigation
Closed
Labels
Milestone
Description
Parent Issue
Part of #561 (Make DocumentDB usable from package install)
Summary
Create a documentdb-setup bash script that automates the full DocumentDB setup in a single command. This is the core deliverable that bridges the gap between package installation and a working DocumentDB instance.
What It Does
The script performs 7 steps in sequence:
- Detect PostgreSQL -- auto-detects PG version and binary paths (Debian/RHEL layout)
- Initialize cluster -- runs
initdb, creates data directory, starts PG on port 9712 - Configure PostgreSQL -- writes drop-in
conf.d/documentdb.confwith all required GUCs, adds HBA entries for TCP localhost, setslisten_addresses - Create extensions --
CREATE EXTENSION documentdb CASCADE(+ extended RUM when available) - Create users -- creates
documentdbPG superuser role (gateway system user) + MongoDB-compatible application user viadocumentdb_api.create_user() - Configure gateway -- updates
SetupConfiguration.jsonwith correct ports - Start gateway -- enables systemd service (or manual start without systemd)
Design Decisions
- Always requires root -- simpler than split root/non-root flow
- Drop-in conf.d -- reversible, does not clobber
postgresql.conf - Merges shared_preload_libraries -- reads existing config, deduplicates
- SQL injection prevention -- uses
jqfor JSON construction + psql variables with heredoc (not-c) + explicit::documentdb_core.bsoncast - Behavioral parity with Docker -- same GUCs as emulator entrypoint (
indexBuildsScheduledOnBgWorker=false,ssl=off, extended RUM GUCs, etc.) - Idempotent -- safe to re-run (skips existing cluster, user, extensions)
--skip-pg-init-- supports existing PostgreSQL clusters- Port collision detection -- verifies running instance data_directory matches expected
- Gateway readiness check -- 60s timeout, fatal on failure
CLI Interface
Usage: documentdb-setup --username <USER> --password <PASS> [OPTIONS]
Required:
--username <USER> MongoDB-compatible username to create
--password <PASS> Password for the user
Options:
--pg-version <VER> PostgreSQL version (auto-detected if not specified)
--pg-port <PORT> PostgreSQL port (default: 9712)
--gateway-port <PORT> Gateway listen port (default: 10260)
--data-dir <DIR> PostgreSQL data directory (default: /var/lib/documentdb/data)
--skip-pg-init Use an existing PostgreSQL cluster
--no-enable Don't start the gateway service
--load-sample-data Load built-in sample data after setup
--pg-owner <USER> PostgreSQL superuser (default: auto-detect)
--verbose Show detailed output
File
scripts/documentdb-setup.sh (~600 lines), installed to /usr/bin/documentdb-setup (755) by the gateway package.
Key Technical Details
- psql
-cdoes NOT perform variable interpolation -- must use heredoc/stdin for:varsyntax documentdb_api.create_user()takesdocumentdb_core.bson, not text -- requires explicit cast- Gateway connects via TCP as user
documentdb-- needs HBA entries + PG role withLOGIN SUPERUSER - Debian PG config lives at
/etc/postgresql/<ver>/<cluster>/, not data_directory -- detect viaSHOW config_file
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
- StatusShow more project fieldsDone
Activity
documentdb-triage-tool commentedon May 30, 2026
👋 @guanzhousongmicrosoft — this issue has been assigned for 30 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 Jun 13, 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.
documentdb-triage-tool commentedon Jun 28, 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.
documentdb-triage-tool commentedon Jul 13, 2026
👋 @guanzhousongmicrosoft — this issue has been assigned for 15 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 Aug 8, 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.
documentdb-triage-tool commentedon Aug 23, 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 Aug 31, 2026
Fixed in v0.116-0: documentdb-setup ships in DEB/RPM packages and works end to end. Closing.