# MongoServerError: mmapv1 锁获取超时

- **ID:** `mongodb/mmapv1-lock-acquire-timeout`
- **领域:** mongodb
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| mongodb-3.2 | active | — | — |
| mongodb-3.4 | active | — | — |
| mongodb-3.6 | active | — | — |

## 解决方案

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.
   ```

## 无效尝试

- **** — Increasing lock timeout just delays failure; the underlying contention remains. (80% 失败率)
- **** — Adding more application threads exacerbates lock contention. (95% 失败率)
