[SERVER-56514] Tests with casual consistency do not wait for the indexes to finish building Created: 30/Apr/21  Updated: 29/Oct/23  Resolved: 02/Jul/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.0.0, 4.2.0
Fix Version/s: 4.2 Required

Type: Bug Priority: Major - P3
Reporter: Nikita Lapkov (Inactive) Assignee: Nikita Lapkov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: JPEG File 1.jpg    
Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0
Sprint: Query Execution 2021-05-03, Query Execution 2021-05-17, Query Execution 2021-05-31, Query Execution 2021-06-14, Query Execution 2021-06-28, Query Execution 2021-07-12
Participants:
Linked BF Score: 17

 Description   

Consider the simple test:

const coll = db.test;
coll.drop();
 
coll.createIndex(/* geospatial index spec */);
coll.insert(/* documents with geospatial data */);
 
coll.find(/* query using $near, $nearSphere or $geoNear */).toArray();

Let us try to execute this test in replica_sets_multi_stmt_txn_terminate_primary_jscore_passthrough suite. Network overrides will add w: "majority" to the createIndex command here. With these settings, the following timeline of execution is possible on MongoDB version 4.2:

First of all, we have 3-node replica set. node2 is Primary, all other nodes are Secondaries. Test issues createIndexes command, it arrives on Primary and command waits until the index is successfully built. To satisfy "majority" write concern, command is replicated to the node1. As soon as command is replicated, createIndexes command returns with success. It does not wait for node1 to finish the index build.

After the createIndexes command, the test suite issues a stepdown of Primary, which triggers a re-election. node1 is now selected as Primary. Note that the index build on node1 is still in progress.

After the new Primary was selected, test issues a find command with $near, $nearSphere or $geoNear operator. All these operators require a geospatial index to work. Since the geospatial index on the current Primary node1 is still building, it is not available for querying. Since there is no geospatial index available, query fails.

Note that starting from version 4.4 createIndexes with write concern "majority" actually waits for the index to finish building on the majority of nodes. So the affected versions are 4.2 and earlier.



 Comments   
Comment by Githook User [ 25/Jun/21 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-56514 Add causally_consistent_index_builds override to replica_sets_multi_stmt_txn_terminate_primary_jscore_passthrough suite
Branch: v4.2
https://github.com/mongodb/mongo/commit/1b5e10ddfd3f70cd28c14c496fc58836f7442f85

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