[SERVER-55111] When using a nested shard key, a delete in a txn to a chunk that has moved is not throwing MigrationConflict Created: 10/Mar/21  Updated: 29/Oct/23  Resolved: 17/May/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 4.9.0-alpha4
Fix Version/s: 5.0.0-rc0

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

Issue Links:
Related
related to SERVER-55033 OpObserverImpl should pass the shard ... Closed
related to SERVER-56127 Retryable update may execute more tha... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2021-04-05, Sharding EMEA 2021-05-03, Sharding EMEA 2021-05-17
Participants:

 Description   

After SERVER-55033 there is still one situation where OpObserverShardingImpl::shardObserveDeleteOp will not throw upon attempting to delete a document in a txn on a chunk that has moved since the atClusterTime. This situation happens when the collection has a nested shard key.

For instance:

OpObserverImpl::getDocumentKey() calls dotted_path_support::extractElementsBasedOnTemplate() and would return an object {"x.y": 10}.

OpObserverShardingImpl::shardObserveDeleteOp() calls ShardKeyPattern::extractShardKeyFromDocThrows() which would fail to find the shard key because there is no field call "x" in the object {"x.y": 10}. There is only a field called "x.y".

Possible solutions could be:
a) Make shardObserveDeleteOp() receive the full document, so it can call extractShardKeyFromDoc() itself. This would likely cause a performance regression since we would need to save a copy of the full document in aboutToDelete().
b) Make shardObserveDeleteOp() receive the shard key (without the _id, unless _id was part of the shard key pattern) so that it can skip calling extractShardKeyFromDoc*() itself. shardObserveDeleteOp() also needs to receive the _id separately so it can be given to MigrationChunkClonerSourceLegacy::onDeleteOp()
c) Make OpObserverImpl::getDocumentKey set the shard key BSONObj as nested object (if the shard key was nested), instead of setting it as dot-notation.



 Comments   
Comment by Githook User [ 17/May/21 ]

Author:

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

Message: SERVER-55111 When using a nested shard key, a delete in a txn to a chunk that has moved is not throwing MigrationConflict
Branch: master
https://github.com/mongodb/mongo/commit/98b60eb0d7a1f7d46415a358378fef1e862d3d32

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