-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Service Arch
-
Fully Compatible
-
Service Arch 2024-03-04, Service Arch 2024-03-18
-
6
ThreadSanitizer reported an data race on OperationContext's comment when AsyncResultMerger triggers an remote getMore request in executor thread.
WARNING: ThreadSanitizer: data race (pid=15366) Read of size 1 at 0x7b54001901e0 by thread T7 (mutexes: write M40668083253752760): #3 mongo::OperationContext::getComment() /data/mci/1f4fee19da4d5e66c402fcf55c759f5e/src/src/mongo/db/operation_context.h:605:16 (libremote_command.so+0xff47) #4 mongo::executor::RemoteCommandRequestBase::RemoteCommandRequestBase(unsigned long, mongo::DatabaseName const&, mongo::BSONObj const&, mongo::BSONObj const&, mongo::OperationContext*, mongo::Duration<std::ratio<1l, 1000l> >, mongo::executor::RemoteCommandRequestBase::Options, boost::optional<mongo::UUID>) /data/mci/1f4fee19da4d5e66c402fcf55c759f5e/src/src/mongo/executor/remote_command_request.cpp:86:30 (libremote_command.so+0xff47) ... #8 mongo::AsyncResultsMerger::_askForNextBatch(mongo::WithLock, unsigned long) /data/mci/e92bfcd96f27e362d85b95eb67a02da8/src/src/mongo/s/query/async_results_merger.cpp:493:36 (libasync_results_merger.so+0x36248) #9 mongo::AsyncResultsMerger::_processBatchResults(mongo::WithLock, mongo::executor::RemoteCommandResponse const&, unsigned long) /data/mci/e92bfcd96f27e362d85b95eb67a02da8/src/src/mongo/s/query/async_results_merger.cpp:816:25 (libasync_results_merger.so+0x3affd) #10 mongo::AsyncResultsMerger::_handleBatchResponse(mongo::WithLock, mongo::executor::TaskExecutor::RemoteCommandCallbackArgs const&, unsigned long) /data/mci/e92bfcd96f27e362d85b95eb67a02da8/src/src/mongo/s/query/async_results_merger.cpp:735:9 (libasync_results_merger.so+0x3a72c) auto mongo::AsyncResultsMerger::_askForNextBatch(mongo::WithLock, unsigned long)::$_3::operator()<mongo::executor::TaskExecutor::RemoteCommandCallbackArgs>(mongo::executor::TaskExecutor::RemoteCommandCallbackArgs const&) const /data/mci/e92bfcd96f27e362d85b95eb67a02da8/src/src/mongo/s/query/async_results_merger.cpp:499:19 (libasync_results_merger.so+0x3cd7f) #12 void std::__invoke_impl<void, mongo::AsyncResultsMerger::_askForNextBatch(mongo::WithLock, unsigned long)::$_3&, mongo::executor::TaskExecutor::RemoteCommandCallbackArgs const&>(std::__invoke_other, mongo::AsyncResultsMerger::_askForNextBatch(mongo::WithLock, unsigned long)::$_3&, mongo::executor::TaskExecutor::RemoteCommandCallbackArgs const&) /opt/mongodbtoolchain/revisions/69f4f0673ffcb290ce2307560a4883ecf2ad138c/stow/gcc-v4.35T/lib/gcc/x86_64-mongodb-linux/11.3.0/../../../../include/c++/11.3.0/bits/invoke.h:61:14 (libasync_results_merger.so+0x3cd7f) Previous write of size 1 at 0x7b54001901e0 by thread T35 (mutexes: write M76133603901300744, write M64311757959123120): .... #3 mongo::OperationContext::setComment(mongo::BSONObj const&) /data/mci/a647d08861b580be2eebaeb30f29e5f1/src/src/mongo/db/operation_context.h:596:18 (libcluster_query.so+0x47011) #4 mongo::(anonymous namespace)::setUpOperationContextStateForGetMore(mongo::OperationContext*, mongo::GetMoreCommandRequest const&, mongo::ClusterCursorManager::PinnedCursor const&) /data/mci/a647d08861b580be2eebaeb30f29e5f1/src/src/mongo/s/query/cluster_find.cpp:636:16 (libcluster_query.so+0x47011) #5 mongo::ClusterFind::runGetMore(mongo::OperationContext*, mongo::GetMoreCommandRequest const&) /data/mci/a647d08861b580be2eebaeb30f29e5f1/src/src/mongo/s/query/cluster_find.cpp:968:9 (libcluster_query.so+0x47011) #6 mongo::(anonymous namespace)::ClusterGetMoreCmdBase<mongo::(anonymous namespace)::ClusterGetMoreCmdS>::Invocation::run(mongo::OperationContext*, mongo::rpc::ReplyBuilderInterface*)
Actually, this is false positive report because the `opCtx->setComment` is always called in client thread before the remote request is triggered. It's not in parallel.