mongodb resource_error ai_generated true

MongoServerError: mmapv1 lock acquire timeout

ID: mongodb/mmapv1-lock-acquire-timeout

Also available as: JSON · Markdown · 中文
90%Fix Rate
85%Confidence
1Evidence
2023-03-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
mongodb-3.2 active
mongodb-3.4 active
mongodb-3.6 active

Root Cause

With the deprecated MMAPv1 storage engine, a write operation waited too long for a database-level lock due to high concurrency.

generic

中文

使用已弃用的 MMAPv1 存储引擎时,由于高并发,写入操作等待数据库级锁超时。

Official Documentation

https://www.mongodb.com/docs/v3.6/faq/storage/#does-mmapv1-have-locking-issues

Workarounds

  1. 95% success Migrate to WiredTiger storage engine which uses document-level concurrency.
    Migrate to WiredTiger storage engine which uses document-level concurrency.
  2. 70% success Reduce write concurrency by batching writes or using a queue to serialize operations.
    Reduce write concurrency by batching writes or using a queue to serialize operations.

中文步骤

  1. Migrate to WiredTiger storage engine which uses document-level concurrency.
  2. Reduce write concurrency by batching writes or using a queue to serialize operations.

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Increasing lock timeout just delays failure; the underlying contention remains.

  2. 95% fail

    Adding more application threads exacerbates lock contention.