[SERVER-62207] ReshardCollection with small maxTimeMS can crash the shard due to incorrect BSON object lifetime Created: 21/Dec/21  Updated: 29/Oct/23  Resolved: 28/Dec/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 5.0.0, 5.2.0, 5.1.0
Fix Version/s: 5.3.0, 5.0.6, 5.2.1

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

Attachments: Text File repro.patch    
Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.2, v5.0
Steps To Reproduce:

repro.patch

./buildscripts/resmoke.py run --storageEngine=wiredTiger --storageEngineCacheSizeGB=.50 --suite=sharding  jstests/sharding/repro.js --log=file

Sprint: Sharding EMEA 2021-12-27
Participants:

 Description   

_shardsvrReshardCollection constructs a ReshardCollectionCoordinator passing as argument 'request()', which contains non-owned BSON objects (in particular, 'key' and 'collation'. ReshardCollectionCoordinator makes a copy of the ShardsvrReshardCollection object, but the mentioned BSON objects are still unowned. Thus, if ReshardCollectionCoordinator outlives the _shardsvrReshardCollection command, a crash can happen because the underlying bson objects are dangling.



 Comments   
Comment by Githook User [ 20/Jan/22 ]

Author:

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

Message: SERVER-62207 Make ReshardCollectionCoordinator store an owned BSON object for the command

(cherry picked from commit 5eab3ca8acaa0e8004c50112187b6809667157a2)
Branch: v5.2
https://github.com/mongodb/mongo/commit/365f5a81cf2da5bcce212e1f48d700c95a5cc639

Comment by Githook User [ 29/Dec/21 ]

Author:

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

Message: SERVER-62207 Make ReshardCollectionCoordinator store an owned BSON object for the command

(cherry picked from commit 5eab3ca8acaa0e8004c50112187b6809667157a2)
Branch: v5.0
https://github.com/mongodb/mongo/commit/1e5c94ab5444a6301974c5a2c4dda9b8ae325168

Comment by Githook User [ 28/Dec/21 ]

Author:

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

Message: SERVER-62207 Make ReshardCollectionCoordinator store an owned BSON object for the command
Branch: master
https://github.com/mongodb/mongo/commit/5eab3ca8acaa0e8004c50112187b6809667157a2

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