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

Affected Versions
Versions known to exhibit this issue

No affected versions recorded.

Fixed Versions
Versions that include the fix
9.1.0-rc09.1.0-rc1025
Components
Server components related to this issue

No components specified.

Labels
Tags and classification

No labels assigned.