[SERVER-54538] Make assertions in thread_context_test thread-safe Created: 12/Feb/21  Updated: 29/Oct/23  Resolved: 13/May/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service Arch 2021-05-17
Participants:
Linked BF Score: 0

 Description   

It is unsafe to assert from the spawned threads in unit-tests, as such assertions are process fatal. We should change the assertions in thread_context_test (e.g., here) to be thread-safe. This could be done by using the ThreadAssertionMonitor.

Moreover, the spawned threads could access non-thread safe metrics (shown below) that are defined here. Accessing these metrics must be serialized (e.g., by using atomics or a mutex) to ensure thread-safety.

class ThreadContextTest : public unittest::Test {
...
private:
    size_t _created;
    size_t _destroyed;
    size_t _destroyedOffThread;
};



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

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-54538 Enable assertions from ThreadContextTest worker threads

Synchronize access to counters.

Make one ThreadAssertionMonitor outside test body, to avoid
implicitly making threads while the test is running.
Branch: master
https://github.com/mongodb/mongo/commit/2070fc76b3604f8c04997862159b0fc721eeb465

Comment by Billy Donahue [ 13/May/21 ]

CR https://mongodbcr.appspot.com/796090047/

Comment by Githook User [ 11/May/21 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: Revert "SERVER-54538 Make assertions in thread_context_test thread-safe"

This reverts commit 496b1a7b6deac14044d870329be2fbe948ad22dd.
Branch: master
https://github.com/mongodb/mongo/commit/07d56bdc7674c0a6181046c469db12ed46a54637

Comment by Githook User [ 10/May/21 ]

Author:

{'name': 'Luis Osta', 'email': 'luis.osta@mongodb.com', 'username': 'LuisOsta'}

Message: SERVER-54538 Make assertions in thread_context_test thread-safe
Branch: master
https://github.com/mongodb/mongo/commit/496b1a7b6deac14044d870329be2fbe948ad22dd

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