[SERVER-73012] Make mongos prioritize primary shard when forwarding analyzeShardKey command Created: 18/Jan/23  Updated: 29/Oct/23  Resolved: 02/Feb/23

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

Type: Task Priority: Major - P3
Reporter: Cheahuychou Mao Assignee: Cheahuychou Mao
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Sharding NYC
Backwards Compatibility: Fully Compatible
Sprint: Sharding NYC 2023-02-06
Participants:

 Description   

The monotonicity check can return an incorrect result if the collection has gone through chunk migrations or resharding since documents are deleted from the donor shard(s) and re-inserted on the recipient shards; so there is no guarantee that the insertion order from the client is preserved. Therefore, the likelihood of a false positive or negative is correlated to the ratio between the number of documents inserted by the client and the number of documents inserted by chunk migration or resharding. 

  • The noise from chunk migration can be and will be mitigated through making mongos prioritize the primary shard when forwarding the analyzeShardKey command since if the collection did not start out as being sharded (which applies to most cases), the primary shard is likely to be the shard with the least number of documents inserted by chunk migrations since all the data starts out there. The database may have had other primary shards, however, movePrimary migrates data by doing a collection scan so it does preserve the original insertion order.
  • The noise from resharding cannot be migrated since there is a systematic way to tell which shard has the least number of documents inserted by resharding. For this project, we will assume that users are unlikely to need to analyze a shard key immediately after resharding has occurred.


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

Author:

{'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}

Message: SERVER-73012 Make mongos prioritize primary shard when forwarding analyzeShardKey command
Branch: master
https://github.com/mongodb/mongo/commit/669b1c04d1a1fec3ee59893750f4c7df507672f7

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