Skip to content
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

Make sure clear the CLUSTER SLOTS cache on time when updating hostname #564

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,7 @@ static int updateClusterIp(const char **err) {
int updateClusterHostname(const char **err) {
UNUSED(err);
clusterUpdateMyselfHostname();
clearCachedClusterSlotsResponse();
enjoy-binbin marked this conversation as resolved.
Show resolved Hide resolved
return 1;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/unit/cluster/hostnames.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ test "Verify cluster-preferred-endpoint-type behavior for redirects and info" {
# Verify prefer hostname behavior
R 0 config set cluster-preferred-endpoint-type hostname

# Make sure the cache is cleared when updating hostname.
R 0 multi
R 0 cluster slots
R 0 config set cluster-announce-hostname "new-me.com"
R 0 cluster slots
set multi_result [R 0 exec]
set slot_result1 [lindex $multi_result 0]
set slot_result2 [lindex $multi_result 2]
assert_equal "me.com" [get_slot_field $slot_result1 0 2 0]
assert_equal "new-me.com" [get_slot_field $slot_result2 0 2 0]

# Set it back to its original value.
R 0 config set cluster-announce-hostname "me.com"

set slot_result [R 0 cluster slots]
assert_equal "me.com" [get_slot_field $slot_result 0 2 0]
assert_equal "them.com" [get_slot_field $slot_result 2 2 0]
Expand Down
Loading