[SERVER-65382] AutoSplitVector should not use clientReadable to reorder shard key fields Created: 08/Apr/22  Updated: 29/Oct/23  Resolved: 16/Aug/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.4.17, 5.0.12, 6.0.2, 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Allison Easton Assignee: Jordi Serra Torrens
Resolution: Fixed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File autosplit.js    
Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0, v5.0, v4.4
Sprint: Sharding EMEA 2022-08-08, Sharding EMEA 2022-08-22
Participants:

 Description   

The clientReadable function converts MinKey into {$minElement: 1} for readability purposes. However, the bsonObj {$minElement: 1} does not compare as less than all values the same way that MinKey does.

This is fine for the prettyKey function for logging, but can cause issues when used in the orderShardKeyFields function, whose results are compared. The repro included in this patch triggers the dassert about shard key ordering because the comparison of null and {$minElement: 1} returns null < {$minElement: 1} while minKey should be less than null.

This problem is also present in splitvector - as part of this ticket we should investigate whether this can cause problems on older versions.



 Comments   
Comment by Githook User [ 23/Aug/22 ]

Author:

{'name': 'Jordi Serra Torrens', 'email': 'jordi.serra-torrens@mongodb.com', 'username': 'jordist'}

Message: SERVER-65382 Don't use clientReadable in AutoSplitVector when reordering shard key fields

(cherry picked from commit 56dab5c0dcfbebcc2f5910a82f78dd4678620532)
Branch: v5.0
https://github.com/mongodb/mongo/commit/233f00f74caa8cf4cf04ad8ca1343a7408949fab

Comment by Benety Goh [ 18/Aug/22 ]

Author:

{'name': 'Jordi Serra Torrens', 'email': 'jordi.serra-torrens@mongodb.com', 'username': 'jordist'}

Message: SERVER-65382 Don't use clientReadable in AutoSplitVector when reordering shard key fields
Branch: master
https://github.com/mongodb/mongo/commit/56dab5c0dcfbebcc2f5910a82f78dd4678620532

Comment by Jordi Serra Torrens [ 10/Aug/22 ]

I believe older versions are also affected by this, but they don't trigger the 'dassert' because it was first introduced on v5.3 by SERVER-58750. In fact, SERVER-58750 removes this sorting of the splitPoints, as it was deemed unnecessary and replaces it by the failing dassert.

So even though it won't hit any dassert on older versions, I think the splitter might still produce incorrect results because of this bug, so I think we should backport the fix.

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