The migration cloner installs itself to the CollectionShardingRuntime while holding the csr lock in exclusive mode. The op observers take the csr lock in shared mode to extract the cloner and capture the write. However, it completely skips this if it cannot find the cloner. Therefore the following scenario is possible:
- Doc A is inserted.
- ThreadA starts a wuow and performs delete on doc A.
- Delete tries to check for cloner and finds out that it is not attached to the csr, so it decides not to capture the write.
- Migration starts and installs cloner to csr.
- Migration clone scans through the collection, clones doc A and gets sent to the recipient shard.
- ThreadA commits wuow.
- Migration finishes and write done by threadA is not transfered.