mongodb data_error ai_generated partial

MongoServerError: 在命名空间 mydb.mycoll 的块迁移期间检测到孤立文档

MongoServerError: orphan documents detected during chunk migration on namespace mydb.mycoll

ID: mongodb/sharded-cluster-orphan-documents

其他格式: JSON · Markdown 中文 · English
75%修复率
82%置信度
1证据数
2024-01-10首次发现

版本兼容性

版本状态引入弃用备注
MongoDB 6.0 active — — —
MongoDB 7.0 active — — —
MongoDB 8.0 active — — —

根因分析

由于并发写入或迁移清理失败,块迁移留下了不属于新分片范围的文档。

English

Chunk migration left behind documents that do not belong to the new shard range due to concurrent writes or a failed migration cleanup.

generic

解决方案

  1. Use the cleanupOrphaned command on the affected shard to remove orphan documents: db.adminCommand({ cleanupOrphaned: 'mydb.mycoll' }).
  2. Temporarily disable the balancer (sh.stopBalancer()) and manually re-migrate the chunk to ensure consistent range coverage.
  3. Verify shard key distribution and adjust chunk boundaries using splitChunk to isolate orphan documents.

无效尝试

常见但无效的做法:

  1. 80% 失败

    Deletion without verifying shard key ranges can cause data loss.

  2. 90% 失败

    Orphans persist after restart unless the balancer re-migrates or cleanup runs.

  3. 50% 失败

    Cleanup may conflict with ongoing balancer operations, requiring repeated runs.