Definition of "single-phase background builds": Index builds started on versions 4.2 and prior; in 4.4, index builds started in FCV 4.2.
Consider the scenario:
- Node 1, Primary, starts and completes a single-phase background index build. It replicates a "createIndexes" oplog entry
- Node 2, Secondary, starts the index build
- Node 2 steps up as primary, but the index build is still incomplete
Say a client created an index and waited for it to complete on the primary before issuing read queries. After the state transition, the client will see that the index build is no longer available for queries until the new primary completes the index build.
Proposed solution: on a state transition to primary, wait for all BackgroundOperations to complete like we already do for rollback.