[SERVER-46656] Secondary and primary can disagree on index build method Created: 05/Mar/20  Updated: 07/Apr/20  Resolved: 10/Mar/20

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Replication, Sharding
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Matthew Russotto Assignee: Benety Goh
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File server_46656.repro    
Issue Links:
Duplicate
duplicates SERVER-46603 disallow empty collection index build... Closed
Related
related to SERVER-47383 Complete TODO listed in SERVER-46656 Closed
is related to SERVER-46817 Primary and secondaries can disagree ... Closed
is related to SERVER-21700 Do not relax constraints during stead... Closed
Operating System: ALL
Sprint: Execution Team 2020-03-23
Participants:

 Description   

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.


Generated at Thu Feb 08 05:12:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.