AuthorizationManagerImpl: Fix thread group thread blocked on condition_variable#293
Conversation
WalkthroughThe PR adds conditional compilation to switch several internal mutex/condition_variable members to coroutine-based types when D_USE_CORO_SYNC is defined, and simplifies lock construction sites to use CTAD or decltype-based lock types. No public API signatures were changed. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (11)
🚧 Files skipped from review as they are similar to previous changes (6)
🧰 Additional context used🧬 Code graph analysis (1)src/mongo/db/auth/authorization_manager_impl.h (1)
🔇 Additional comments (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/mongo/db/logical_session_cache_impl.h (1)
42-44: Note: Conditional compilation pattern differs from other files.This file uses
#ifdef D_USE_CORO_SYNCwhile other files use#ifndef D_USE_CORO_SYNC. Both are logically correct, but the inconsistency may reduce maintainability.Consider aligning with the pattern used in other files for consistency:
-#ifdef D_USE_CORO_SYNC +#ifndef D_USE_CORO_SYNC + mutable stdx::mutex _reaperMutex; +#else #include "mongo/db/coro_sync.h" -#endif - -namespace mongo { -... -#ifndef D_USE_CORO_SYNC - mutable stdx::mutex _reaperMutex; -#else mutable coro::Mutex _reaperMutex; #endifAlso applies to: 165-169, 172-176
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/mongo/db/auth/authorization_manager_impl.cpp(2 hunks)src/mongo/db/auth/authorization_manager_impl.h(4 hunks)src/mongo/db/keys_collection_cache.cpp(5 hunks)src/mongo/db/keys_collection_cache.h(2 hunks)src/mongo/db/logical_session_cache_impl.cpp(15 hunks)src/mongo/db/logical_session_cache_impl.h(2 hunks)src/mongo/db/query/plan_cache.cpp(7 hunks)src/mongo/db/query/plan_cache.h(2 hunks)src/mongo/db/time_proof_service.cpp(2 hunks)src/mongo/db/time_proof_service.h(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/mongo/db/query/plan_cache.cpp (1)
src/mongo/db/logical_session_cache_impl.cpp (2)
size(169-172)size(169-169)
src/mongo/db/auth/authorization_manager_impl.h (1)
src/mongo/db/coro_sync.h (3)
coro(30-115)Mutex(42-55)ConditionVariable(57-114)
src/mongo/db/logical_session_cache_impl.h (1)
src/mongo/db/coro_sync.h (2)
coro(30-115)Mutex(42-55)
src/mongo/db/query/plan_cache.h (1)
src/mongo/db/coro_sync.h (2)
coro(30-115)Mutex(42-55)
🔇 Additional comments (11)
src/mongo/db/keys_collection_cache.h (1)
37-41: LGTM! Conditional compilation setup is clean.The conditional includes and mutex type switching are well-structured and maintain API compatibility.
Also applies to: 75-79
src/mongo/db/keys_collection_cache.cpp (1)
48-48: LGTM! CTAD usage simplifies lock declarations.The switch to Class Template Argument Deduction for
lock_guardis appropriate and works seamlessly with bothstdx::mutexandcoro::Mutextypes.Also applies to: 65-65, 88-88, 105-105, 120-120
src/mongo/db/auth/authorization_manager_impl.h (1)
52-57: LGTM! Conditional synchronization primitives properly configured.The dual-path implementation correctly switches between
stdxandcorosynchronization primitives while preserving the public API.Also applies to: 204-208, 244-259
src/mongo/db/auth/authorization_manager_impl.cpp (2)
249-249: LGTM! Proper use ofdecltypefor member variable.Using
decltype(AuthorizationManagerImpl::_cacheMutex)is the correct approach for deducing the lock type in a member variable declaration, as CTAD doesn't apply to member variables.
327-327: LGTM! CTAD simplifies local lock declaration.The type deduction for
unique_lockis appropriate for local variables and works with both mutex types.src/mongo/db/query/plan_cache.cpp (1)
750-750: LGTM! Consistent CTAD usage across all locking sites.The migration to type-deduced
lock_guardis systematic and correct across all methods.Also applies to: 765-765, 785-785, 802-802, 807-807, 823-823, 837-837, 849-849, 854-854
src/mongo/db/time_proof_service.cpp (1)
59-59: LGTM! CTAD usage is consistent.The simplified lock declarations align with the broader PR pattern and work correctly with both mutex types.
Also applies to: 84-84
src/mongo/db/query/plan_cache.h (1)
42-46: LGTM! Conditional compilation is properly structured.The mutex type switching follows the established pattern and maintains a clean separation between the two synchronization implementations.
Also applies to: 430-434
src/mongo/db/logical_session_cache_impl.cpp (1)
95-95: LGTM: Clean adoption of CTAD for lock_guard.The removal of explicit template parameters throughout the file is a correct and beneficial modernization. Using Class Template Argument Deduction (CTAD) simplifies the syntax while maintaining identical semantics. These changes work correctly with the conditional mutex types introduced elsewhere in the PR (stdx::mutex vs. coro::Mutex), as both provide compatible lock interfaces.
Also applies to: 170-170, 198-198, 229-229, 233-233, 242-242, 254-254, 269-269, 302-302, 313-313, 346-346, 354-354, 367-367, 397-397, 403-403, 408-408, 414-414, 423-423, 434-434, 447-447
src/mongo/db/time_proof_service.h (2)
34-39: Conditional compilation pattern looks correct.The conditional include structure properly switches between stdx and coro synchronization headers based on the D_USE_CORO_SYNC macro, maintaining consistency with similar changes across the PR.
97-101: Conditional mutex declaration is correct; coro::Mutex is the primary tested implementation.The D_USE_CORO_SYNC flag is unconditionally defined in service_context.h, making coro::Mutex the standard code path throughout the codebase. The conditional pattern used in time_proof_service.h follows the established convention across multiple components (authorization_manager_impl, session_catalog, plan_cache, etc.). Since coro::Mutex is the active implementation in normal builds, its compatibility with stdx::lock_guard is already verified through existing test coverage.
fe06230 to
49db161
Compare
… blocked on pthread condition_variable (#293)
Summary by CodeRabbit