Subchapter 63.8
references/upgrade.mdMarkdown7 KBView on GitHub
Orchestrate DocumentDB major version upgrades. Supports two paths:
Two approaches:
Scripts
Wa ReviewCannot skip versions (3.6 must go 3.6->5.0->8.0). Elastic Clusters: MVU is not supported — no workaround. Global Clusters: direct in-place MVU is not supported. Workaround: remove the cluster from the Global Cluster first (this converts it to a standalone regional cluster), perform the upgrade using Option A or B below, then re-add it to the Global Cluster.
aws docdb describe-db-clusters --query 'DBClusters[0].EngineVersion')5.0 or 8.0)app_name (artifact naming)Mandatory on every modify-db-cluster MVU command: --allow-major-version-upgrade. When cluster uses a custom parameter group: also --db-cluster-parameter-group-name pointing at a new PG for the target engine family (docdb5.0, docdb8.0).
Pre-upgrade checks:
aws docdb wait is not in all CLI versions)db.r4 instances (not supported on 4.0+) — upgrade to db.r5+ firstdb.t4g.medium <= 3,000 indexes, db.t3.medium <= 10,000. If over, scale primary to db.r5.large before upgradingaws docdb create-db-cluster-snapshot \
--db-cluster-identifier <id> \
--db-cluster-snapshot-identifier <id>-pre-mvu-$(date +%Y%m%d) \
--region <region>Poll until Status=available.
aws docdb create-db-cluster-parameter-group \
--db-cluster-parameter-group-name <id>-docdb<version>-pg \
--db-parameter-group-family docdb<version> \
--description "MVU target for <id>" --region <region>aws docdb modify-db-cluster \
--db-cluster-identifier <id> \
--engine-version <target-version> \
--db-cluster-parameter-group-name <id>-docdb<version>-pg \
--allow-major-version-upgrade --apply-immediately \
--region <region>Cluster unavailable during upgrade (multiple reboots). Time depends on collection / index / instance count.
# Engine version
aws docdb describe-db-clusters --db-cluster-identifier <id> \
--query 'DBClusters[0].EngineVersion' --region <region>
# Confirm via mongosh: db.version() and db.runCommand({ping: 1})For 5.0->8.0: wait for “Index metadata refresh process completed” event (up to 2 hours). Do NOT reboot, failover, or scale the writer during this time.
Custom parameter group required (defaults can’t be modified). After switching to a custom PG, reboot the instance and confirm DBClusterParameterGroupStatus=in-sync before proceeding:
change_stream_log_retention_duration = 86400 # 24 hoursEnable change streams on all databases:
db.adminCommand({ modifyChangeStreams: 1, database: "", collection: "", enable: true })aws docdb restore-db-cluster-to-point-in-time \
--db-cluster-identifier <id>-clone \
--source-db-cluster-identifier <id> \
--use-latest-restorable-time \
--region <region>Record clone creation time (DMS CDC start = 2 min before, as Unix epoch). Add instances to the clone and wait for available.
Apply Option A Steps 2–4 to the clone. Do NOT write to the clone after it’s upgraded.
Follow references/migration.md for DMS setup:
--ssl-mode verify-full and the cert ARNsuccessful)Then create the replication task with migration-type cdc (data changes only — clone already has the data) and CDC start time = 2 minutes before clone creation:
aws dms create-replication-task \
--replication-task-identifier <id>-mvu-cdc \
--source-endpoint-arn <source-ep-arn> \
--target-endpoint-arn <clone-ep-arn> \
--replication-instance-arn <dms-instance-arn> \
--migration-type cdc \
--cdc-start-position "checkpoint:<2-min-before-clone-time-epoch>" \
--table-mappings '{"rules":[{"rule-type":"selection","rule-id":"1","rule-name":"all","object-locator":{"schema-name":"%","table-name":"%"},"rule-action":"include"}]}' \
--replication-task-settings '{"ErrorBehavior":{"FailOnNoTablesCaptured":false}}' \
--region <region>Start the task. Monitor CDCLatencySource — should decrease toward 0.
Fallback: amazon-documentdb-tools/migration/mvu-tool/mvu-cdc-migrator.py. Source URI MUST NOT include readPreference=secondaryPreferred (change streams are primary-only).
CDCLatencySource < 60s)Before cutover: delete the clone; source is untouched.
aws docdb delete-db-cluster --db-cluster-identifier <clone-id> --skip-final-snapshotAfter cutover, within 24–48 hours: point app back at source (still has data up to cutover). Manual reconciliation needed for writes made to the clone after cutover.
If source was already deleted: restore from the pre-upgrade snapshot:
aws docdb restore-db-cluster-from-snapshot \
--db-cluster-identifier <id>-restored \
--snapshot-identifier <pre-upgrade-snapshot-id> --engine docdb4.0 -> 5.0: Vector search, LZ4 compression (off by default), I/O-Optimized storage, partial indexes, text indexes v1. Recommended but optional: db.collection.reIndex() on low-cardinality indexes.
5.0 -> 8.0: Query Planner v3 (7× faster aggregations), Zstd compression (on by default, 5× ratio), Text v2 parser, Collation (default-on), Views, new stages ($merge, $bucket, $replaceWith, $vectorSearch), 30× faster vector index builds. No index rebuild needed. Update driver to MongoDB 6.0+/7.0+/8.0 to use new features.