summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2022-08-22 10:12:55 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-22 17:47:42 +0000
commit017318d3281c4b6f04dfdfd74ad382c6354191cb (patch)
tree4522f48e69a1f44a04e6e7a0f564894a8d44e448
parent7013e5f7c9ec106c0b8b5ee376c2064148bf7dcf (diff)
downloadmongo-017318d3281c4b6f04dfdfd74ad382c6354191cb.tar.gz
SERVER-68482 Add MONGO_TSAN_IGNORE to getFlowControlStats
-rw-r--r--src/mongo/db/concurrency/lock_state.cpp23
-rw-r--r--src/mongo/db/concurrency/lock_state.h4
2 files changed, 17 insertions, 10 deletions
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp
index 4897d881e83..f0e3caf4ce4 100644
--- a/src/mongo/db/concurrency/lock_state.cpp
+++ b/src/mongo/db/concurrency/lock_state.cpp
@@ -58,6 +58,15 @@ MONGO_FAIL_POINT_DEFINE(enableTestOnlyFlagforRSTL);
namespace {
+// Ignore data races in certain functions when running with TSAN. For performance reasons,
+// diagnostic commands are expected to race with concurrent lock acquisitions while gathering
+// statistics.
+#if defined(__has_feature) && __has_feature(thread_sanitizer)
+#define MONGO_TSAN_IGNORE __attribute__((no_sanitize("thread")))
+#else
+#define MONGO_TSAN_IGNORE
+#endif
+
/**
* Tracks global (across all clients) lock acquisition statistics, partitioned into multiple
* buckets to minimize concurrent access conflicts.
@@ -693,13 +702,7 @@ ResourceId LockerImpl::getWaitingResource() const {
return _waitingResource;
}
-// Ignore data races in this function when running with TSAN. For performance reasons, diagnostic
-// commands are expected to race with concurrent lock acquisitions while gathering statistics.
-#if defined(__has_feature)
-#if __has_feature(thread_sanitizer)
-__attribute__((no_sanitize("thread")))
-#endif
-#endif
+MONGO_TSAN_IGNORE
void LockerImpl::getLockerInfo(LockerInfo* lockerInfo,
const boost::optional<SingleThreadedLockStats> lockStatsBase) const {
invariant(lockerInfo);
@@ -839,6 +842,12 @@ void LockerImpl::restoreLockState(OperationContext* opCtx, const Locker::LockSna
invariant(_modeForTicket != MODE_NONE);
}
+MONGO_TSAN_IGNORE
+FlowControlTicketholder::CurOp LockerImpl::getFlowControlStats() const {
+ return _flowControlStats;
+}
+
+MONGO_TSAN_IGNORE
LockResult LockerImpl::_lockBegin(OperationContext* opCtx, ResourceId resId, LockMode mode) {
dassert(!getWaitingResource().isValid());
diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h
index 8fe6f1a0e1b..4bb786ea02f 100644
--- a/src/mongo/db/concurrency/lock_state.h
+++ b/src/mongo/db/concurrency/lock_state.h
@@ -208,9 +208,7 @@ public:
void getFlowControlTicket(OperationContext* opCtx, LockMode lockMode) override;
- FlowControlTicketholder::CurOp getFlowControlStats() const override {
- return _flowControlStats;
- }
+ FlowControlTicketholder::CurOp getFlowControlStats() const override;
//
// Below functions are for testing only.