[SERVER-75443] PinnedConnectionTaskExecutor::join needs to wait for all networking to finish Created: 29/Mar/23  Updated: 29/Oct/23  Resolved: 30/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.0.0-rc0, 6.0.6

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

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.3, v6.0
Sprint: Service Arch 2023-04-03
Participants:
Linked BF Score: 44

 Description   

Currently, PinnedConnectionTaskExecutor::join returns early if the RPC requestQueue is empty. But it's possible for a request to have been popped from the queue, but for it to still be being worked on. That means it's possible for threads to be running the continuation in this: https://github.com/mongodb/mongo/blob/58a69ba924e2ca557bf1c208fed59fc948107bd0/src/mongo/executor/pinned_connection_task_executor.cpp#L283 getAsync, after join has returned. If join() returning is the only thing preventing PCTE from being destroyed, this means that continuation can read garbage data because it is using "this" after it is freed, and it can cause invariant-failures if the PCTE destructor finds that the PCTE::_mutex is being held by the thread running that continuation. 

We should ensure that join waits for any in-progress requests to be done before returning. We should also consider joining the scoped task executor, and having that getAsync keep a shared_ptr to "this".



 Comments   
Comment by Githook User [ 29/Mar/23 ]

Author:

{'name': 'George Wangensteen', 'email': 'george.wangensteen@mongodb.com', 'username': 'gewa24'}

Message: SERVER-75443 PinnedConnectionTaskExecutor::join waits for in-progress requests to finish even if they are already out of the request queue
Branch: master
https://github.com/mongodb/mongo/commit/f0faf5547f917c2b69959a9c4771b67719d8dbee

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