-
Notifications
You must be signed in to change notification settings - Fork 416
tests: Fix concurrency of accessing fail_point_val #10702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: JaySon-Huang <[email protected]>
📝 WalkthroughWalkthroughIntroduces mutex-based synchronization in FailPointHelper: new Changes
Sequence Diagram(s)(Skipped) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses a TSAN-reported data race on FailPointHelper::fail_point_val where concurrent threads could access the map while one thread is modifying it (e.g., one thread reading via getFailPointVal while another thread erases via disableFailPoint).
Changes:
- Added
std::shared_mutex fail_point_val_mutexto protect concurrent access tofail_point_val - Protected read access in
getFailPointValwithstd::shared_lock - Protected write access in
enableFailPointanddisableFailPointwithstd::unique_lock
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dbms/src/Common/FailPoint.h | Added declaration of fail_point_val_mutex with appropriate #ifdef FIU_ENABLE guards and included <shared_mutex> header |
| dbms/src/Common/FailPoint.cpp | Defined fail_point_val_mutex and added locking in getFailPointVal, enableFailPoint, and disableFailPoint methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@dbms/src/Common/FailPoint.cpp`:
- Around line 365-375: The throw in FailPointHelper::wait should include a
specific ErrorCodes value and use fmt::format instead of string concatenation;
replace the current throw Exception(...) with one that passes
ErrorCodes::FAIL_POINT_ERROR and a formatted message built via fmt::format
(referencing FailPointHelper::wait, fail_point_wait_channels, and the Exception
constructor that accepts an error code) so the exception becomes
Exception(ErrorCodes::FAIL_POINT_ERROR, fmt::format("Can not find channel for
fail point {}", fail_point_name)).
🧹 Nitpick comments (1)
dbms/src/Common/FailPoint.cpp (1)
214-218: Rename new static members to camelCase.
New variables use snake_case, which conflicts with the C++ naming guideline. ConsiderfailPointWaitChannelsMutex,failPointValMutex, andfailPointVal(orfailPointValMap) and update the header usages accordingly.As per coding guidelines: Method and variable names in C++ must use camelCase (e.g.,
readBlock,totalBytes).
Signed-off-by: JaySon-Huang <[email protected]>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JinheLin The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@dbms/src/Common/FailPoint.cpp`:
- Around line 214-218: The static member names use snake_case; rename them to
camelCase and update all declarations/usages: change
FailPointHelper::fail_point_wait_channels_mutex ->
FailPointHelper::failPointWaitChannelsMutex,
FailPointHelper::fail_point_wait_channels ->
FailPointHelper::failPointWaitChannels, FailPointHelper::fail_point_val_mutex ->
FailPointHelper::failPointValMutex, and FailPointHelper::fail_point_val ->
FailPointHelper::failPointVal; ensure you update the corresponding declarations
in the FailPoint.h header and any references throughout the codebase to match
the new names so linkage and compilation remain correct.
What problem does this PR solve?
Issue Number: close #10683
Problem Summary:
FailPointHelper::fail_point_valwhen one thread disables a failpoint while another reads it.What is changed and how it works?
fail_point_valwithstd::shared_mutexand use shared/unique locks for read/write access.Check List
Tests
Side effects
Documentation
Release note
Summary by CodeRabbit