mongodb
data_error
ai_generated
partial
MongoServerError: orphan documents detected during chunk migration on namespace mydb.mycoll
ID: mongodb/sharded-cluster-orphan-documents
75%Fix Rate
82%Confidence
1Evidence
2024-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| MongoDB 6.0 | active | — | — | — |
| MongoDB 7.0 | active | — | — | — |
| MongoDB 8.0 | active | — | — | — |
Root Cause
Chunk migration left behind documents that do not belong to the new shard range due to concurrent writes or a failed migration cleanup.
generic中文
由于并发写入或迁移清理失败,块迁移留下了不属于新分片范围的文档。
Workarounds
-
80% success Use the cleanupOrphaned command on the affected shard to remove orphan documents: db.adminCommand({ cleanupOrphaned: 'mydb.mycoll' }).
Use the cleanupOrphaned command on the affected shard to remove orphan documents: db.adminCommand({ cleanupOrphaned: 'mydb.mycoll' }). -
85% success Temporarily disable the balancer (sh.stopBalancer()) and manually re-migrate the chunk to ensure consistent range coverage.
Temporarily disable the balancer (sh.stopBalancer()) and manually re-migrate the chunk to ensure consistent range coverage.
-
70% success Verify shard key distribution and adjust chunk boundaries using splitChunk to isolate orphan documents.
Verify shard key distribution and adjust chunk boundaries using splitChunk to isolate orphan documents.
中文步骤
Use the cleanupOrphaned command on the affected shard to remove orphan documents: db.adminCommand({ cleanupOrphaned: 'mydb.mycoll' }).Temporarily disable the balancer (sh.stopBalancer()) and manually re-migrate the chunk to ensure consistent range coverage.
Verify shard key distribution and adjust chunk boundaries using splitChunk to isolate orphan documents.
Dead Ends
Common approaches that don't work:
-
80% fail
Deletion without verifying shard key ranges can cause data loss.
-
90% fail
Orphans persist after restart unless the balancer re-migrates or cleanup runs.
-
50% fail
Cleanup may conflict with ongoing balancer operations, requiring repeated runs.