[SERVER-65259] Cursor leak in aggregation that requires merging on shard Created: 05/Apr/22  Updated: 29/Oct/23  Resolved: 21/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.4.19, 5.0.15, 6.0.4, 6.2.0-rc0

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

Attachments: Text File 0001-Repro-SERVER-65259.patch    
Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.1, v6.0, v5.0, v4.4
Steps To Reproduce:

./buildscripts/resmoke.py run --storageEngine=wiredTiger --storageEngineCacheSizeGB=.50 --suite=sharding jstests/sharding/repro-server-65259.js --log=file
0001-Repro-SERVER-65259.patch

Sprint: QE 2022-09-19, QE 2022-10-03
Participants:
Linked BF Score: 4

 Description   

Consider an aggregation that requires merging on a shard. First, mongos opens the split cursors on the shards. Later, in order to establish the merge cursor, dispatchMergingPipeline is called and the split cursors ownership is transferred to it. There, sharded_agg_helpers::addMergeCursorsSource will transfer the split cursors ownership to the merge pipeline. Finally, the merge cursor will be established. However, if this fails (for instance if the shard is in the middle of a migration critical section), 'storePossibleCursor' will return here and then the split cursors ownership is dismissed from the mergePipeline. However, because the merge cursor was not really established, the shard did not take ownership of those cursors either, so they are leaked.



 Comments   
Comment by Githook User [ 16/Dec/22 ]

Author:

{'name': 'Mickey. J Winters', 'email': 'mickey.winters@mongodb.com', 'username': 'mjrb'}

Message: SERVER-65259 fix cursor leak in aggregation that requires merging on shard

(cherry-picked from commit 7f40c171562cb8de1dfae04368ca54e44a193f96)
Branch: v5.0
https://github.com/mongodb/mongo/commit/6530690040dca4c52b78b2f268e31bf11a015131

Comment by Githook User [ 16/Dec/22 ]

Author:

{'name': 'Mickey. J Winters', 'email': 'mickey.winters@mongodb.com', 'username': 'mjrb'}

Message: SERVER-65259 fix cursor leak in aggregation that requires merging on shard

(cherry-picked from commit 7f40c171562cb8de1dfae04368ca54e44a193f96)
Branch: v4.4
https://github.com/mongodb/mongo/commit/ca6b6dc8eb0a0bd527f812f4fb1196794ccd1a83

Comment by Githook User [ 15/Dec/22 ]

Author:

{'name': 'Mickey. J Winters', 'email': 'mickey.winters@mongodb.com', 'username': 'mjrb'}

Message: SERVER-65259 fix cursor leak in aggregation that requires merging on shard

(cherry-picked from commit 7f40c171562cb8de1dfae04368ca54e44a193f96)
Branch: v6.0
https://github.com/mongodb/mongo/commit/b953dbf36cba018c98a407d362580ed9ed9b9d23

Comment by Mickey Winters [ 20/Sep/22 ]

Because SERVER-6036 was not backported to 4.2 I think this isn't an issue on 4.2 because eventually the cursor would be timed out and killed

Comment by Githook User [ 16/Sep/22 ]

Author:

{'name': 'Mickey. J Winters', 'email': 'mickey.winters@mongodb.com', 'username': 'mjrb'}

Message: SERVER-65259 fix cursor leak in aggregation that requires merging on shard
Branch: master
https://github.com/mongodb/mongo/commit/7f40c171562cb8de1dfae04368ca54e44a193f96

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