[SERVER-45107] Using removeExistingIndexes in conjunction with createIndexesOnEmptyCollection results in out of order index fields. Created: 12/Dec/19  Updated: 29/Oct/23  Resolved: 13/Dec/19

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: 4.3.3

Type: Bug Priority: Major - P3
Reporter: Maria van Keulen Assignee: Maria van Keulen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2019-12-16
Participants:
Linked BF Score: 47

 Description   

There are several places in the code base that call into IndexBuildsCoordinator's static createIndexesOnEmptyCollection function to create an index, as opposed to going through the IndexBuildsCoordinator itself. To prepare the index specs for creation, these callers use IndexCatalog::removeExistingIndexes. However, these index specs result in out-of-order fields compared to index builds that use the IndexBuildsCoordinator, because the IndexCatalog::prepareSpecForCreate function, which is called via MultiIndexBlock, re-orders the fields. Even though IndexCatalog::removeExistingIndexes does call IndexCatalog::prepareSpecForCreate, the spec objects returned by prepareSpecForCreate are unused.

The implication of this bug is the oplog entries for different index builds will have a different ordering of subfields inside the "o" field.

Using the return result of prepareSpecForCreate in the return result of removeExistingIndexes should address the ordering inconsistency.



 Comments   
Comment by Githook User [ 13/Dec/19 ]

Author:

{'name': 'Maria van Keulen', 'email': 'maria.vankeulen@mongodb.com', 'username': 'mvankeulen94'}

Message: SERVER-45107 Reorder index spec fields during removeExistingIndexes

IndexCatalog::removeExistingIndexes is used in several places
to prepare index specs for creation via the IndexBuildsCoordinator's
static createIndexesOnEmptyCollection function. The former function
indirectly calls IndexCatalog::prepareSpecForCreate, but only uses
the return result to check a status. prepareSpecForCreate is directly
called in other index build paths via MultiIndexBlock, where its
return result is used. Because prepareSpecForCreate has a side-
effect of reordering index spec fields, not using its return value
in removeExistingIndexes results in the spec having a different order
of fields from these other paths.
Branch: master
https://github.com/mongodb/mongo/commit/9ea1f7a6d9322d70ae5080a1f93e9952449b14fa

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