All Products
Search
Document Center

ApsaraDB for MongoDB:Why upgrade to a later MongoDB version

Last Updated:Apr 01, 2026

MongoDB 4.4 reached End of Life (EOL) in February 2024. Continuing to run an EOL version means you no longer receive security patches, bug fixes, or support. More importantly, ApsaraDB for MongoDB has documented specific kernel bugs and operational risks in versions 4.4 and earlier — some rated High severity — that are resolved only by upgrading.

Upgrade to MongoDB 5.0, 6.0, 7.0, or 8.0. For version lifecycle dates, see Lifecycle Schedules.

Risks in earlier versions

The ApsaraDB for MongoDB team identified the following risks based on long-term cloud database operations experience.

Orphaned documents cause data inconsistency during migration

  • Affected versions: Sharded cluster instances running MongoDB 4.2 or later

  • Fix version: MongoDB 4.4 or later

After a chunk migrates from a source shard to a destination shard, the source shard retains the chunk temporarily before deletion. Migration interruptions leave behind orphaned documents. Orphaned documents do not affect requests on mongos nodes because the requests are checked by the routing data of ConfigServer nodes. However, orphaned documents accumulate and cause data inconsistency during subsequent migrations.

MongoDB 4.4 introduced self-recovery chunk migration and automatic orphaned document cleanup. If nodes fail mid-migration, MongoDB resumes the process automatically — no need to run cleanupOrphaned manually. Run the command only to confirm that background cleanup threads are active.

For details, see cleanupOrphaned.

The compact command blocks reads and writes

  • Affected versions: All architectures running MongoDB 4.2 or earlier

  • Fix version: MongoDB 4.4 or later

Running compact to defragment a disk on MongoDB 4.2 or earlier blocks all read and write operations for the duration. The operation cannot be interrupted, so the only recovery option is to restart the instance, which affects business continuity.

MongoDB 4.4 optimized the locking behavior of compact so that CRUD operations are not blocked. Only some DDL operations — createIndex and dropIndex — are briefly affected. Schedule compact runs outside your maintenance window.

Note

To defragment a disk, we recommend that you use the storage analysis feature provided by ApsaraDB for MongoDB.

For details, see Defragment the disks of an instance and compact blocking.

The compact command causes nodes to enter the RECOVERING state

  • Affected versions: All architectures with major version MongoDB 4.2 or earlier and minor version earlier than 4.2.18

  • Fix version: MongoDB 4.4 or later

On affected versions, running compact causes mongos nodes to enter the RECOVERING state. If nodes remain in this state long enough, the ApsaraDB for MongoDB activation component treats them as unhealthy and triggers a rebuild, causing unplanned downtime.

Starting from MongoDB 4.2.18, mongos nodes no longer enter the RECOVERING state after compact runs, preventing both unavailable nodes and unexpected rebuild flows.

Note

To defragment a disk, we recommend that you use the storage analysis feature provided by ApsaraDB for MongoDB.

For details, see Defragment the disks of an instance and compact RECOVERING.

Physical backups on hidden nodes consume excessive disk space

  • Affected versions: All architectures running MongoDB 4.2 or earlier that use local disks

  • Fix version: MongoDB 5.0 or later (cloud disks)

The physical backup mechanism on local-disk instances causes disk file sizes to grow continuously during backup uploads. Large accumulated files consume significant disk space and trigger incorrect disk usage alerts during node failures or switchovers.

Cloud-disk instances combine physical backup with disk snapshots, reducing the time required to maintain WiredTiger (WT) backup checkpoints and resolving disk space bloat on hidden nodes. For replica set instances with more than 2 TB of data, use snapshot backup to avoid the long backup times, high failure rates, and O&M operation conflicts that occur with local-disk physical backups.

Residual routing data breaks databases recreated with the same name

  • Affected versions: Sharded cluster instances running MongoDB 4.4 or earlier

  • Fix version: MongoDB 5.0 or later

When you drop a database with dropDatabase in a sharded cluster and then recreate a database with the same name, residual routing data in the ConfigServer node causes read and write operations to fail.

On MongoDB 4.2 or earlier, you must run dropDatabase repeatedly and then run flushRouterConfig on all mongos nodes to flush routing data — otherwise residual data degrades performance.

MongoDB 5.0 optimized dropDatabase routing data handling so that routing data is automatically cleared, eliminating this manual cleanup requirement.

For details, see dropDatabase and flushRouterConfig.

Default write concern {w:1} causes data sync failures on secondary nodes

  • Affected versions: All architectures running versions earlier than MongoDB 5.0

  • Fix version: MongoDB 5.0 or later

With the default write concern of {w:1}, data written rapidly to the primary node may only partially reach secondary nodes, causing them to enter the RECOVERING state. This degrades instance availability, breaks read/write splitting workloads, and prevents incremental backups and point-in-time recovery.

MongoDB 5.0 changed the default write concern from {w:1} to {w:"majority"}. Data is queryable only after the majority of replica set members confirm the write, improving data reliability at a slight performance loss. For high-write-throughput scenarios where you can accept the previous behavior, set write concern back to {w:1}.

For details, see Default write concern and setDefaultRWConcern.

The balancer rebalances data too slowly to support scale-out

  • Affected versions: All architectures running versions earlier than MongoDB 5.0

  • Fix version: MongoDB 5.0 or later

The balancer cannot migrate chunks fast enough to rebalance data during scale-out events, which degrades performance as data remains unevenly distributed across shards.

MongoDB 5.0 added chunkMigrationConcurrency and balancerMigrationsThrottlingMs parameters so you can tune balancer migration concurrency and throughput to match your workload.

Note

If your instance is already on MongoDB 5.0 but these parameters are unavailable, update to a later minor version. See Update the minor version of an instance.

For details, see chunkMigrationConcurrency and balancerMigrationsThrottlingMs.

Chunk-count-based balancing causes load imbalance in sharded clusters

  • Affected versions: All architectures with major version MongoDB 5.0 or earlier and minor version earlier than 6.0.3

  • Fix version: MongoDB 6.0 or later

The balancer distributes data based on chunk count rather than data volume. When jumbo chunks or empty chunks exist — or when a subset of data receives disproportionately high traffic — chunks appear balanced by count but shards carry unequal load.

MongoDB 6.0.3 changed the balancer to distribute data based on the difference in data volume across shards rather than chunk count. This resolves load imbalance caused by jumbo chunks, empty chunks, and hot data patterns.

For details, see Changes to the balancer in MongoDB 6.0.3.

Other kernel issues

The following table lists additional kernel issues in earlier MongoDB versions identified by the ApsaraDB for MongoDB team.

Version Issue Risk level Trigger and description
MongoDB 3.4 SERVER-34192 SERVER-20328 SERVER-21307 Medium Trigger: Read/write splitting is enabled. Issue: Global locks are acquired when secondary nodes replay oplogs, causing slow requests.
MongoDB 4.0 SERVER-70783 Low Trigger: Server connection count increases significantly. Issue: Assertions are triggered by insufficient sessions, causing mongos node failures and switchovers.
MongoDB 3.6–4.2 SERVER-40535 Low Trigger: Occasional. Issue: Cache Reader No keys found for HMAC that is valid for time error; retry logic is required.
MongoDB 4.2 or earlier SERVER-43641 SERVER-51803 Low Trigger: Occasional; related to /dev/urandom. Issue: mongos nodes crash and automatically recover after restart.
MongoDB 4.0–4.2 SERVER-43889 Low Trigger: Occasional. Issue: The server cannot distinguish transactions from retryable writes, causing request failures.
MongoDB 4.0–4.4 SERVER-51281 SERVER-50365 High Trigger: Long-running transactions. Issue: The write-through cache fails to evict, dirty cache lines exceed 20%, and transaction cleanup threads get stuck — causing significant request latency increases and degraded performance.
MongoDB 3.6–4.4 SERVER-52654 High Trigger: ConfigServer nodes have not switched in 90 days. Issue: Hash-based Message Authentication Code (HMAC) key generation failures on ConfigServer nodes cause mongos nodes to crash and fail to recover automatically.
MongoDB 4.0–4.4 SERVER-53566 Medium Trigger: Occasional. Issue: An opContext assertion error causes mongod to crash and triggers a switchover.
MongoDB 4.4 or earlier SERVER-21307 High Trigger: DDL operations are recorded in oplogs during background index creation on secondary nodes. Issue: DDL operations are blocked and secondary nodes fail.
MongoDB 4.4 or earlier WT-5809 Medium Trigger: Node restart or data sync initialization. Issue: Temporal ordering issues in the WiredTiger history store trigger a WT assertion error, causing mongod to crash.
MongoDB 4.2–4.4 SERVER-51041 High Trigger: Read/write splitting is enabled and secondary node load is high. Issue: POSIX thread mutex contention exhausts read tickets on secondary nodes, degrading performance.
MongoDB 4.2–4.4 SERVER-52556 SERVER-66176 Medium Trigger: Application frequently calls listCollections. Issue: Mutex lock contention in the underlying CollectionCatalog component significantly degrades performance.
MongoDB 6.0 or earlier SERVER-63865 SERVER-67038 SERVER-69877 High Trigger: Out-of-memory (OOM) error during index creation. Issue: mongod repeatedly restarts and fails to recover. If two replica set nodes enter this state, the instance becomes unavailable.
MongoDB 6.0 or earlier SERVER-56194 Low Trigger: Large numbers of expired documents after creating Time to Live (TTL) indexes or modifying expiration times. Issue: Backend TTL threads get stuck and fail to recover, causing the TTL feature to stop working.

New features in later versions

Version Feature Description
MongoDB 5.0 Time series collections Efficient storage and querying of time series data for Internet of Vehicles (IoV) and Internet of Things (IoT) scenarios.
Long-running snapshot queries Read historical snapshots without affecting ongoing operations.
Versioned API Decouples the application lifecycle from the database lifecycle. Applications remain fully compatible across database version upgrades — no compatibility remediation required.
MongoDB 6.0 Change streams Pre-change views are now available. Execution efficiency and resource utilization are improved. Orphaned document updates can be filtered. More DDL change events are supported, enhancing Change Data Capture (CDC) support.
JOIN queries in sharded clusters Sharded cluster instances support $lookup and $graphLookup operators for JOIN queries, with improved operator performance.
Automatic defragmentation in sharded clusters Use configureCollectionBalancing to specify chunk sizes per shard and enable automatic defragmentation — no need to run compact manually in sharded clusters.
Time series collection improvements Sharding support, columnar compression to reduce storage usage, secondary and compound indexes for read performance, geospatial indexes for spatio-temporal data, and optimized time series sorting.
Enhanced compact command Fully optimized compact in WiredTiger with significantly improved performance and fewer eviction-caused failures.
MongoDB 7.0 Shard key analysis Analyze sampled query results to assess whether a collection's shard key is optimal. Use this to configure schemas and shard keys more efficiently.
Queryable encryption Encrypts sensitive data throughout its entire lifecycle — in transit, at rest, in use, in logs, and in backups. Data is decrypted only on the client, significantly reducing data leak risks from theft.
Metadata consistency check Automatically detects metadata and index inconsistencies after a maintenance window ends or after exceptions such as OOM errors or failovers.
Large change events in change streams The $changeStreamSplitLargeEvent operator splits change events larger than 16 MB, resolving the limitation in earlier versions where large events caused change stream failures.
Dynamic throttling in WiredTiger Dynamically adjusts WiredTiger transaction concurrency (default: 128) to prevent database failures from request accumulation after exceptions.
MongoDB 8.0 Advanced TCMalloc Uses per-CPU caches instead of per-thread caches to reduce memory fragmentation and handle heavier workloads. A background thread releases memory to the operating system every second.
Optimized replication performance With write concern set to majority, MongoDB returns after oplogs are written to most replica members rather than waiting for the change to be applied — improving write throughput. Secondary nodes also write and apply oplog batches in parallel: a Writer thread reads from the primary and writes to the local oplog while an Applier thread asynchronously applies changes to the local database.
Optimized resharding Improved reshardCollection performance for changing a collection's shard key and data distribution.

References