-
Notifications
You must be signed in to change notification settings - Fork 955
Add CLUSTER FLUSHSLOT command #1384
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c2a3757
add cluster flushslot command.
wuranxx 15c056b
Add TCL tests and optimize code structure.
wuranxx 61af84d
Fix compile warning.
wuranxx 384599f
Fix delKeysInSlot does not consider command invoke.
wuranxx ff3afe0
1. Move clusterCommandFlushslot to cluster.c
wuranxx a72fa59
Fix bool issue
hwware 50fb27d
Adjust format for cluster_legacy.c
hwware 04ac837
Adjust code format for cluster_legacy.c
hwware 19814d5
Remove newline
hwware f6f258e
Update src/cluster_legacy.c
wuranxx aad606d
Update src/cluster_legacy.c
wuranxx 4fb08a9
Update src/commands/cluster-flushslot.json
wuranxx 5fc6fe6
Update src/commands/cluster-flushslot.json
wuranxx 050eacd
Update src/commands/cluster-flushslot.json
wuranxx 3829d38
Update src/commands/cluster-flushslot.json
wuranxx ee303ae
add flushslot command propagate test.
wuranxx ddfa7ff
change tcl test use assert_match and assert_no_match.
wuranxx 245f1d2
Merge branch 'unstable' into cluster-flush-slot
wuranxx 4742800
Merge branch 'unstable' into cluster-flush-slot
wuranxx e37a8c2
add `propagate_del` and `send_del_event` parameters to `delKeysInSlot`.
wuranxx e7c9be7
fix code format.
wuranxx 62593e4
Merge branch 'valkey-io:unstable' into cluster-flush-slot
wuranxx 9a2839e
Remove `since` from `cluster-flushslot` options definition.
wuranxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "FLUSHSLOT": { | ||
| "summary": "Remove all keys from the target slot.", | ||
| "complexity": "O(N) where N is the number of keys in the target slot", | ||
| "group": "cluster", | ||
| "since": "9.0.0", | ||
| "arity": -3, | ||
| "container": "CLUSTER", | ||
| "function": "clusterCommand", | ||
| "command_flags": [ | ||
| "WRITE", | ||
| "NO_ASYNC_LOADING", | ||
| "ADMIN" | ||
| ], | ||
| "acl_categories": [ | ||
| "KEYSPACE" | ||
| ], | ||
| "reply_schema": { | ||
| "const": "OK" | ||
| }, | ||
| "arguments": [ | ||
| { | ||
| "name": "slot", | ||
| "type": "integer" | ||
| }, | ||
| { | ||
| "name": "flush-type", | ||
| "type": "oneof", | ||
| "optional": true, | ||
| "arguments": [ | ||
| { | ||
| "name": "async", | ||
| "type": "pure-token", | ||
| "token": "ASYNC" | ||
| }, | ||
| { | ||
| "name": "sync", | ||
| "type": "pure-token", | ||
| "token": "SYNC" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| start_cluster 2 2 {tags {external:skip cluster}} { | ||
| test "SYNC Flush slot command" { | ||
| set key_slot [R 0 CLUSTER KEYSLOT FC] | ||
| set slot_keys_num [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] | ||
|
|
||
| # set key | ||
| for {set i 0} {$i < 1000} {incr i} { | ||
| R 0 set "{FC}-$i" "value" | ||
| } | ||
| set after_keys_num [expr {$slot_keys_num + 1000}] | ||
| assert_equal [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] $after_keys_num | ||
|
|
||
| # flush slot key | ||
| R 0 CLUSTER FLUSHSLOT $key_slot SYNC | ||
| assert_equal [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] 0 | ||
| } | ||
|
|
||
| test "ASYNC Flush slot command" { | ||
| set key_slot [R 0 CLUSTER KEYSLOT FC] | ||
| set slot_keys_num [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] | ||
|
|
||
| # set key | ||
| for {set i 0} {$i < 1000} {incr i} { | ||
| R 0 set "{FC}-$i" "value" | ||
| } | ||
| set after_keys_num [expr {$slot_keys_num + 1000}] | ||
| assert_equal [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] $after_keys_num | ||
|
|
||
| # flush slot key | ||
| R 0 CLUSTER FLUSHSLOT $key_slot ASYNC | ||
| assert_equal [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] 0 | ||
| } | ||
| } | ||
enjoy-binbin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| start_cluster 2 2 {tags {external:skip cluster}} { | ||
| test "Flush slot command propagated to replica" { | ||
| set key_slot [R 0 CLUSTER KEYSLOT FC] | ||
| set slot_keys_num [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] | ||
|
|
||
| # set key | ||
| for {set i 0} {$i < 1000} {incr i} { | ||
| R 0 set "{FC}-$i" "value" | ||
| } | ||
| set after_keys_num [expr {$slot_keys_num + 1000}] | ||
| assert_equal [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] $after_keys_num | ||
|
|
||
| # flush slot key | ||
| R 0 CLUSTER FLUSHSLOT $key_slot SYNC | ||
| assert_equal [R 0 CLUSTER COUNTKEYSINSLOT $key_slot] 0 | ||
|
|
||
| # assert flush slot propagated to replica | ||
| for {set l 0} {$l < 4} {incr l} { | ||
| puts "R $l info:" | ||
| puts [R $l info replication] | ||
| puts [R $l info commandSTATS] | ||
| } | ||
|
|
||
| set info [R 2 info commandSTATS] | ||
| # not del cmd | ||
| assert_no_match "*cmdstat_del*" $info | ||
| # has flushslot cmd | ||
| assert_match "*cmdstat_cluster|flushslot:calls=1*" $info | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.