-
Notifications
You must be signed in to change notification settings - Fork 480
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
Support watch/unwatch commands #1279
Conversation
This PR is generally good for me, to see if other folks have comments. @torwig @ShooterIT @caipengbo |
There's one corner case that may also modify the key as well:
so we should also update them if the key is modified, others are good to me. |
Done. |
Thanks all. Merging... Feel free to open an issue if there is anything you are concerning about this PR later. |
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.
So, here it has:
Server:
watched shared lock
map: <key, connections>
watched_key_size_
Connection:
1. watch changed
2. watched key sets
All watched data is controlled by shared lock in Server, and only the function modify the Server maping would grab the write-lock. Am I right?
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.
Rest LGTM
Great work! |
The old code call ResetWatchedKeys before the error, and then ResetWatchedKeys reset watched_keys_modified flag which cause the following inconsistencies (with Redis). kvrocks output: ``` 127.0.0.1:6666> watch a OK 127.0.0.1:6666> watch b ->>> other client touch a OK 127.0.0.1:6666> exec (error) ERR EXEC without MULTI 127.0.0.1:6666> multi OK 127.0.0.1:6666(TX)> ping QUEUED 127.0.0.1:6666(TX)> exec 1) PONG ``` redis output: ``` 127.0.0.1:6379> watch a OK 127.0.0.1:6379> watch b ->>> other client touch a OK 127.0.0.1:6379> exec (error) ERR EXEC without MULTI 127.0.0.1:6379> multi OK 127.0.0.1:6379(TX)> ping QUEUED 127.0.0.1:6379(TX)> exec (nil) ```` Introduced in apache#1279
The old code called ResetWatchedKeys before the error, and then ResetWatchedKeys reset the watched_keys_modified flag which causes the following inconsistencies (with Redis). kvrocks output: ``` 127.0.0.1:6666> watch a OK 127.0.0.1:6666> watch b ->>> other client touch a OK 127.0.0.1:6666> exec (error) ERR EXEC without MULTI 127.0.0.1:6666> multi OK 127.0.0.1:6666(TX)> ping QUEUED 127.0.0.1:6666(TX)> exec 1) PONG ``` redis output: ``` 127.0.0.1:6379> watch a OK 127.0.0.1:6379> watch b ->>> other client touch a OK 127.0.0.1:6379> exec (error) ERR EXEC without MULTI 127.0.0.1:6379> multi OK 127.0.0.1:6379(TX)> ping QUEUED 127.0.0.1:6379(TX)> exec (nil) ```` Introduced in #1279
The old code called ResetWatchedKeys before the error, and then ResetWatchedKeys reset the watched_keys_modified flag which causes the following inconsistencies (with Redis). kvrocks output: ``` 127.0.0.1:6666> watch a OK 127.0.0.1:6666> watch b ->>> other client touch a OK 127.0.0.1:6666> exec (error) ERR EXEC without MULTI 127.0.0.1:6666> multi OK 127.0.0.1:6666(TX)> ping QUEUED 127.0.0.1:6666(TX)> exec 1) PONG ``` redis output: ``` 127.0.0.1:6379> watch a OK 127.0.0.1:6379> watch b ->>> other client touch a OK 127.0.0.1:6379> exec (error) ERR EXEC without MULTI 127.0.0.1:6379> multi OK 127.0.0.1:6379(TX)> ping QUEUED 127.0.0.1:6379(TX)> exec (nil) ```` Introduced in apache#1279
The old code called ResetWatchedKeys before the error, and then ResetWatchedKeys reset the watched_keys_modified flag which causes the following inconsistencies (with Redis). kvrocks output: ``` 127.0.0.1:6666> watch a OK 127.0.0.1:6666> watch b ->>> other client touch a OK 127.0.0.1:6666> exec (error) ERR EXEC without MULTI 127.0.0.1:6666> multi OK 127.0.0.1:6666(TX)> ping QUEUED 127.0.0.1:6666(TX)> exec 1) PONG ``` redis output: ``` 127.0.0.1:6379> watch a OK 127.0.0.1:6379> watch b ->>> other client touch a OK 127.0.0.1:6379> exec (error) ERR EXEC without MULTI 127.0.0.1:6379> multi OK 127.0.0.1:6379(TX)> ping QUEUED 127.0.0.1:6379(TX)> exec (nil) ```` Introduced in #1279
It closes #315.
As described in #315 (comment), we follow the "by command & key tracing" method instead of "by snapshots".
NOTE: key expire / rocksdb storage change monitoring has not been implemented