-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Index Maintenance, Replication, Sharding
-
None
-
ALL
-
Execution Team 2020-03-23
The two-phase index build code has an optimization to use single-phase builds on empty collections. In this case it (correctly) writes a "createIndexes" oplog entry instead of the "startIndexBuild"/"commitIndexBuild" pair. However, this optimization is bypassed on some occasions, in particular when moving the primary shard using the database cloner
https://github.com/mongodb/mongo/blob/35a5d455672e65127a24e7cdb98ea1472124af4a/src/mongo/db/cloner.cpp#L405
This results in a "startIndexBuild"/"commitIndexBuild" pair being written on the primary. However, when the secondary does the startIndexBuild, it will notice that the collection is empty and do a single-phase index build. When the commit is executed, it will see that no build is in progress, attempt to start one, and get an IndexAlreadyExists error.
I believe the fix is ensuring that the secondary never applies the optimization for startIndexBuild; if the primary did a two-phase build, the secondary should as well.
- duplicates
-
SERVER-46603 disallow empty collection index build optimization on secondaries
- Closed
- is related to
-
SERVER-46817 Primary and secondaries can disagree on indexBuildsCoordinator worker thread availability
- Closed
-
SERVER-21700 Do not relax constraints during steady state replication
- Closed
- related to
-
SERVER-47383 Complete TODO listed in SERVER-46656
- Closed