[SERVER-19127] unittest::Test::stopCapturingLogMessages has a sometimes fatal race condition Created: 25/Jun/15  Updated: 25/Jan/17  Resolved: 25/Jun/15

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.1.5

Type: Bug Priority: Major - P3
Reporter: Andy Schwerin Assignee: Andy Schwerin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 5 06/26/16
Participants:
Linked BF Score: 0

 Description   

The unittest framework offers a facility for capturing log lines for analysis. That framework is not thread safe. The contract for appenders in the logging system is that they must be internally synchronized, and furthermore, the process of attaching and detaching appenders must be externally synchronized.

Tests that use this facility and also launch multiple threads can crash if the log capture process is disabled while logging is happening, or if several threads are logging at once. Both of these problems should be mitigated.



 Comments   
Comment by Githook User [ 25/Jun/15 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}

Message: SERVER-19127 Fix race condition in unittest log line capturing.

The approach of this fix is to first make the appender for capturing log lines
thread safe, and then to make it very unlikely that bad things happen if a test
races between logging and detaching the special capture appender. We make it
unlikely by taking advantage of the fact that appenders are removed by setting a
pointer in a vector to NULL, and make sure that the capture appender is not
destroyed when it is detached, but rather when the test fixture destructor runs.
This means that if logging only occurs while a test fixture exists (likely if
tests don't start threads outside of fixtures), tests will not try to use a
capture appender that has gone out of scope.
Branch: master
https://github.com/mongodb/mongo/commit/9e0e9bfe233c2600a1b61d5ae45af807da79b824

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