-
Notifications
You must be signed in to change notification settings - Fork 472
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
Fix data race for accessing database in some commands #253
Conversation
Result of this PR:
|
Good catch, many thanks to @calvinxiao. maybe we should integrate some sanitizers into CI to help us find out those issues. |
localtime_r was the same with localtime, except using the user storage buf
It shouldn't use LockGuard here since it would release after exiting |
@git-hulk Looking at all the usage of |
nice! also fixed that too |
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.
nice! also fixed that too
I saw you fixed them in #256 , why not use unique_ptr
?
We lock/unlock manually seems fine within few return branches |
Both were ok for me, I’ll glad to close it if you fix those issues in this PR. |
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.
LGTM
They are not only warnings of compiler but bugs |
@Mergifyio backport 1.3 |
Before this commit, in spop, zremrangebylex, zremrangebyscore commands, the lock guard for accessing database may not work actually. Other changes - Use 'localtime_r' instead of 'localtime' - Use 'std::this_thread::get_id()' to get thread id (cherry picked from commit 1ac04ca)
Command
|
Before this commit, in spop, zremrangebylex, zremrangebyscore commands, the lock guard for accessing the database may not work actually. Other changes - Use 'localtime_r' instead of 'localtime' - Use 'std::this_thread::get_id()' to get thread id (cherry picked from commit 1ac04ca) Co-authored-by: Calvin Xiao <calvin325@gmail.com>
Before this commit, in spop, zremrangebylex, zremrangebyscore commands, the lock guard for accessing database may not work actually. Other changes - Use 'localtime_r' instead of 'localtime' - Use 'std::this_thread::get_id()' to get thread id
Describe this PR
Found several data races with
-fsanitize=thread
flags1. Data race when starting up the server
Output:
2. Thread Sanitizer warning in
make test
3. Thread Sanitizer warning when benchmarking
Benchmark command
redis-benchmark -p 6666 -n 100000 -q
Full output
Part of the output:
Steps to reproduce
-fsanitize=thread
to compiler flagsg++ -v
./src/kvrocks -c kvrocks.conf
make test
redis-benchmark -p 6666 -n 100000 -q
Questions:
localtime_r
?LockGuard
is called at the end ofif
block, is it standard behavior across all C++ versions?