[SERVER-37156] benchRun should wait for the worker threads it spawns to exit Created: 15/Sep/18  Updated: 29/Oct/23  Resolved: 17/Sep/18

Status: Closed
Project: Core Server
Component/s: Performance
Affects Version/s: None
Fix Version/s: 4.0.3, 4.1.4

Type: Task Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
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
Backport Requested:
v4.0
Sprint: TIG 2018-09-24
Participants:
Linked BF Score: 26

 Description   

benchRun() calls .detach() on the worker threads it spawns. This means that despite calling _brState.waitForState(BenchRunState::BRS_FINISHED) to wait for the worker threads to not be considered "active", it doesn't wait for the worker threads to actually be destructed. There is then a race in mongoebench where the destructor for the thread_local ServiceContext::UniqueClient currentClient may not have run by the point embedded::shutdown() is called. Having benchRun() explicitly .join() the worker threads it spawns would fix this race.

void BenchRunWorker::start() {
    stdx::thread([this] { run(); }).detach();
}



 Comments   
Comment by Githook User [ 22/Sep/18 ]

Author:

{'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com', 'username': 'visemet'}

Message: SERVER-37156 Wait for worker threads to exit in benchRun().

(cherry picked from commit 12dba1e5b8c5ec7532da1bfa2e05c56f021d7f06)
Branch: v4.0
https://github.com/mongodb/mongo/commit/4fb0584284b2c04b67de206ad84f8b46421ed0ea

Comment by Githook User [ 17/Sep/18 ]

Author:

{'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com', 'username': 'visemet'}

Message: SERVER-37156 Wait for worker threads to exit in benchRun().
Branch: master
https://github.com/mongodb/mongo/commit/12dba1e5b8c5ec7532da1bfa2e05c56f021d7f06

Generated at Thu Feb 08 04:45:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.