SERVER-138021ClosedFixed
Harden num_orphan_docs.js against stale secondary reads
In chunkMigration, there is a document for the donor and recipient in {{{}config.rangeDeletions{}}}. As documents are copied to the recipient, the recipient document increments its {{numOrphanDocs}} . For example, 2 documents are copied and the recipient document has a {{numOrphanDocs}} count of 2 (the purpose of the recipient document is to delete these orphans on abort), BUT {{pending: true}} is set, which means it's not finalized yet. So then what's happening is {{analyzeShardKey}} queries