mongodb
runtime_error
ai_generated
partial
MongoServerError: Shard key range deletion conflict: range [minKey, maxKey) on shard 'shard01' has pending deletions
ID: mongodb/shard-key-range-deletion-conflict
80%Fix Rate
84%Confidence
1Evidence
2024-06-18First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| mongodb 6.0 | active | — | — | — |
| mongodb 7.0 | active | — | — | — |
| mongodb 8.0 | active | — | — | — |
Root Cause
A chunk migration or drop command failed because the target range has pending deletion tasks from a previous migration, causing a lock conflict.
generic中文
由于目标范围存在先前迁移的待处理删除任务,导致块迁移或删除命令失败,引发锁冲突。
Official Documentation
https://www.mongodb.com/docs/manual/core/sharding-balancer-administration/#chunk-migration-failuresWorkarounds
-
75% success Wait for pending deletions to complete by monitoring the `config.chunks` collection: `db.getSiblingDB('config').chunks.find({ shard: 'shard01', lastmodEpoch: ... })` and check for `pending` flags; retry after 60 seconds.
Wait for pending deletions to complete by monitoring the `config.chunks` collection: `db.getSiblingDB('config').chunks.find({ shard: 'shard01', lastmodEpoch: ... })` and check for `pending` flags; retry after 60 seconds. -
85% success Manually clear pending range deletions using the internal command: `db.adminCommand({ _configsvrCommitRangeDeletion: 'config.system.chunks', range: { min: minKey, max: maxKey }, shard: 'shard01' })` (requires admin privileges and caution).
Manually clear pending range deletions using the internal command: `db.adminCommand({ _configsvrCommitRangeDeletion: 'config.system.chunks', range: { min: minKey, max: maxKey }, shard: 'shard01' })` (requires admin privileges and caution). -
80% success Disable the balancer temporarily: `sh.stopBalancer(60000)` and then manually force a cleanup with `db.adminCommand({ cleanupOrphaned: 'mydb.mycoll', startingFromKey: minKey })` on the affected shard.
Disable the balancer temporarily: `sh.stopBalancer(60000)` and then manually force a cleanup with `db.adminCommand({ cleanupOrphaned: 'mydb.mycoll', startingFromKey: minKey })` on the affected shard.
中文步骤
Wait for pending deletions to complete by monitoring the `config.chunks` collection: `db.getSiblingDB('config').chunks.find({ shard: 'shard01', lastmodEpoch: ... })` and check for `pending` flags; retry after 60 seconds.Manually clear pending range deletions using the internal command: `db.adminCommand({ _configsvrCommitRangeDeletion: 'config.system.chunks', range: { min: minKey, max: maxKey }, shard: 'shard01' })` (requires admin privileges and caution).Disable the balancer temporarily: `sh.stopBalancer(60000)` and then manually force a cleanup with `db.adminCommand({ cleanupOrphaned: 'mydb.mycoll', startingFromKey: minKey })` on the affected shard.
Dead Ends
Common approaches that don't work:
-
90% fail
Pending deletions are internal metadata (range deletion tasks), not user documents; manual deletes do not affect them and may corrupt shard metadata.
-
85% fail
Restarting clears in-memory state but the pending deletion tasks are persisted in config server metadata; they will resume after restart.
-
80% fail
Splitting a range with pending deletions can cause orphaned documents and inconsistent metadata; the operation is rejected by the balancer.