[SERVER-74235] Create compound indexes before sharding collections in refine_collection_shard_key_crud_ops.js Created: 21/Feb/23  Updated: 29/Oct/23  Resolved: 02/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 6.3.0-rc0
Fix Version/s: 7.0.0-rc0

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

Issue Links:
Backports
Depends
Problem/Incident
is caused by SERVER-43099 Reenable random chunk migration failp... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.3
Sprint: Sharding EMEA 2023-03-06
Participants:
Linked BF Score: 0

 Description   

Creating the compound index AFTER sharding the collection potentially allows the balancer to kick-in in the middle leading to a failure when trying to refine the shard key.

Lengthy explanation
During test setup the following actions are performed in a loop that goes from fsmcoll0_25 to fsmcoll0_0:

Aftwerards, refine happens as part of the refineCollectionShardKey state.

A test failure signaled that shard0 did not seem to have the index {a:1, b:1} for test15_fsmdb0.fsmcoll0_25 when trying to refine the shard key from {a:1} to {a:1, b:1}. Question is: why was the index created during the setup not found when trying to refine the shard key?

From the logs we can see that:

  1. The primary shard for test15_fsmdb0 is shard1
  2. The collection gets sharded
  3. The balancer kicks in right when the doc is inserted in config.collections
  4. A migration starts from shard1 to shard0
  5. The refined index is created
  6. The migration succeeds

The migration started on (4) resulted in the recipient cloning the indexes before (5). Hence the index was never created on shard0 because createIndex is not serialized with migrations and is only sent with a scatter gather by routing table to the shards owning chunks (so - at time 4.5 - only to shard1).



 Comments   
Comment by Githook User [ 02/Mar/23 ]

Author:

{'name': 'Pierlauro Sciarelli', 'email': 'pierlauro.sciarelli@mongodb.com', 'username': 'pierlauro'}

Message: SERVER-74235 Create compound indexes before sharding collections in refine_collection_shard_key_crud_ops.js
Branch: master
https://github.com/mongodb/mongo/commit/1e62aa7aa34e190e844ee7728960b8ac78d9fe92

Generated at Thu Feb 08 06:26:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.