24 — LockTimeout

performanceconcurrency

The operation could not acquire a lock within the timeout period

What is happening?

LockTimeout means a MongoDB operation waited for a lock longer than the configured timeout and was abandoned. MongoDB uses reader-writer locks at the database and collection level. Heavy concurrent write operations or long-running transactions can cause lock contention.

Common causes

  1. Long-running transaction holding a write lock
  2. Background index build competing with write operations
  3. High write concurrency on the same collection
  4. DDL operation (rename, drop) blocked by active cursors

Source code references

ErrorCodes::LockTimeout found in 33 locations in the MongoDB server source.

Diagnostic Steps

Related Issues

SERVER-137356Closed
Allow passing fassertOnLockTimeoutForStepUpDown to replSetStepDown to override RSTL timeout
Apply Stripe patch #2: [https://github.com/10gen/mongo/tree/brad.cater/stripe-patch-2-timeout-stepdown-command]   * Specify a timeout value, which is generally configured via server param fassertOnLockTimeoutForStepUpDown, so that the timeout period can be tuned per call/stepDown rather than having to change the server params. * This ticket is limited to configuring this additional parameter on ASC.  Acceptance Criteria: pass the fassertOnLockTimeoutForStepUpDownOverride parameter through
SERVER-137357Closed
DSC/ASC discrepancy: DSC does not use fassertOnLockTimeoutForStepUpDown during RSTL acquisition
ASC makes use of global server parameter fassertOnLockTimeoutForStepUpDown to trigger timeouts during RSTL acquisition. DSC does not access this value; investigate why and if there is any benefit to adding this timeout mechanism to DSC. Acceptance Criteria: Make a decision on whether to utilize the timeout server parameter in DSC.  - If yes, consider threading the additional parameter fassertOnLockTimeoutForStepUpDownOverride through the DSC code to override the existing server parameter whe
SERVER-137287Closed
Skip move range coordinator warning assertion in last-patch multiversion suites
{{chunk_migration_does_not_block_indefinitely_acquiring_strong_locks.js}} [coordinator-warning assertion|https://github.com/10gen/mongo/blob/d51d25a14a958dc1fbfbae477eb405f4b8b8c4e8/jstests/sharding/chunk_migration_does_not_block_indefinitely_acquiring_strong_locks.js#L82-L85] fails in the 9.0 {{sharding_last_patch}} suite when the donor runs 9.0.4. In particular, the migration correctly returns {{{}LockTimeout{}}}, and writes complete successfully. However, 9.0.4 logs the coordinator failure as