Details
-
Task
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
None
-
Sharding NYC
-
Fully Compatible
-
Sharding NYC 2023-02-06
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.