During the collection cloning phase, the _id index build should not be committed before duplicate documents are deleted here. This is because after the index is committed, it is possible to unindex a record with the same key, but a different RecordId.
To make this work, the following straightforward changes will also need to be made:
- call drainBackgroundWrites and checkConstraints before committing the index build. This is because the prior call to deleteDocument performs a side write that must be drained
- update requiresGhostCommitTimestampForWrite to return false if the member is in the STARTUP2 state. This is because lastApplied is not available in at this phase of initial sync.
- don't pass secDups for non-_id indexes here. This is an existing bug because it's possible for the x_1 index to have duplicates, which should be ignored. Unfortunately because the number of initial sync attempts defaulted to 10, this was not evident.
- the initial syncing node must only have 1 attempt in this test. Pass the numInitialSyncAttempts=1 setParameter when adding the node here.