-
Notifications
You must be signed in to change notification settings - Fork 324
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
[db]fix counting_index data race #3651
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3651 +/- ##
==========================================
- Coverage 74.95% 74.69% -0.27%
==========================================
Files 269 266 -3
Lines 23819 23759 -60
==========================================
- Hits 17854 17747 -107
- Misses 5039 5085 +46
- Partials 926 927 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
} | ||
|
||
// Size returns the total number of keys so far | ||
func (c *countingIndex) Size() uint64 { | ||
return c.size | ||
return atomic.LoadUint64(&c.size) |
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.
add another func
func (c *countingIndex) Add(n uint64) {
atomic.StoreUint64(&c.size, c.Size()+n)
}
read use c.Size(), update use c.Add(). maybe better
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description
When testing the analyser, it was found that db counting_index.go has a data race
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: