50 — MaxTimeMSExpired

queryperformancetimeout

The operation exceeded its maxTimeMS time limit

What is happening?

MaxTimeMSExpired indicates the operation did not complete within the maxTimeMS limit. This typically points to a slow query, a missing index, or a server under heavy load. The maxTimeMS option can be set per-operation to prevent long-running queries from consuming server resources indefinitely.

Common causes

  1. Missing or inefficient index for the query pattern
  2. Collection scan on a large collection
  3. Server under heavy CPU or I/O load
  4. maxTimeMS set too low for the expected query duration
  5. Lock contention from concurrent operations

Source code references

ErrorCodes::MaxTimeMSExpired found in 62 locations in the MongoDB server source.

Diagnostic Steps

Related Issues

SERVER-96344Open
mongos doesn't honor a failpoint's full blockTimeMS
The behavior of {{MaxTimeMSExpired}} differs between mongod and mongos when using a blocking failpoint: - mongod: Returns {{MaxTimeMSExpired}} after {{max(blockTimeMS, maxTimeMS)}}. - mongos: Returns {{MaxTimeMSExpired}} after maxTimeMS only. Repro: https://gist.github.com/prestonvasquez/d4b8193b4f67750994051ca61d8f035a results for mongos: results for mongod: Failpoints should be uniform across topologies, behaving as mongod does. In particular, (for sharded clusters) drivers
SERVER-139082Closed
Enable multikey_timestamp_mixed_transaction_large_oplog_batches.js in no_passthrough_disagg_override_replsets
The test pauses secondary replication using {{stopReplProducer}} before executing its mixed workload. DSC bypasses the conventional oplog fetcher that checks this failpoint, so the test waits 10 minutes and fails with {{MaxTimeMSExpired}} before exercising its multikey timestamp assertions. As part of this ticket, we have to adapt this test by using {{pauseOplogApplication}} on the secondary when running under DSC. We have then enable the test in {{no_passthrough_disagg_override_replsets.}}
SERVER-139083Closed
Enable multikey_timestamp_transaction_large_apply_ops.js in no_passthrough_disagg_override_replsets
The test pauses secondary replication using {{stopReplProducer}} before executing a transaction large enough to produce multiple {{applyOps}} oplog entries. DSC bypasses the conventional oplog fetcher that checks this failpoint, so the test waits 10 minutes and fails with {{MaxTimeMSExpired}} before exercising its multikey timestamp assertions. As part of this ticket, use {{pauseOplogApplication}} on the secondary when running under DSC and enable the test in {{no_passthrough_disagg_override_
SERVER-130169Closed
X.509 cluster-membership separation check can fail open on user lookup errors and grant internal authorization
Related to CVE-690 Engineering Work and SECBUG-1282 h1. Security Context See SECBUG-1282 for problem description, security impact, affected conditions, reproduction steps, and severity rationale. h1. Root Cause * src/mongo/db/commands/authentication_commands.cpp: user-existence check collapses all non-OK results into "user absent" via .isOK(); ErrorCodes::UserNotFound and transient failures (MaxTimeMSExpired, NotPrimary, lock timeout, Interrupted) are indistinguishable to the caller * s
SERVER-137718Open
max_time_ms_mongos_deadline.js counts config server connections as shard connection churn
h2. Problem {{jstests/noPassthrough/network/max_time_ms_mongos_deadline.js}} asserts that mongos creates no new egress connections while a find hits MaxTimeMSExpired on the shard. Its helper {{getShardHostPoolStats()}} sums {{connPoolStats.hosts}} over every host, including the config server replica set members. Shortly after startup, mongos issues config reads with nearest read preference. When such a read lands on a config node that has no pooled connection yet, mongos opens a new connec