github-actions[bot] commented on code in PR #63109:
URL: https://github.com/apache/doris/pull/63109#discussion_r3246343233
##########
be/src/common/thread_safety_annotations.h:
##########
@@ -119,6 +141,32 @@ class SCOPED_CAPABILITY LockGuard {
MutexType& _mu;
};
+// RAII scoped shared lock guard annotated for thread safety analysis.
+// In BE_TEST builds, injects a random sleep before acquiring and after
+// releasing the lock to exercise concurrent code paths.
+template <typename MutexType>
+class SCOPED_CAPABILITY SharedLockGuard {
+public:
+ explicit SharedLockGuard(MutexType& mu) ACQUIRE_SHARED(mu) : _mu(mu) {
+#ifdef BE_TEST
+ doris::mock_random_sleep();
+#endif
+ _mu.lock_shared();
Review Comment:
`SharedLockGuard` acquires a shared capability via `ACQUIRE_SHARED(mu)`, but
the destructor is annotated with `RELEASE()`, which is the exclusive-capability
release annotation. That means Clang's thread-safety model will not correctly
pair the shared acquisition/release for this RAII guard, defeating the purpose
of using it for `REQUIRES_SHARED`/`GUARDED_BY` checking. Please release the
shared capability here.
```suggestion
~SharedLockGuard() RELEASE_SHARED() {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]