Skip to content

Commit

Permalink
Remove cluster_fail_reason cluster info field
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Nov 26, 2024
1 parent 4716e66 commit d814cda
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define CLUSTER_NAMELEN 40 /* sha1 hex length */

/* Reason why the cluster state changes to fail. When adding new reasons,
* make sure to update getClusterFailReasonString and clusterLogFailReason. */
* make sure to update clusterLogFailReason. */
#define CLUSTER_FAIL_NONE 0
#define CLUSTER_FAIL_NOT_FULL_COVERAGE 1
#define CLUSTER_FAIL_MINORITY_PARTITION 2
Expand Down
12 changes: 1 addition & 11 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -5363,15 +5363,6 @@ void clusterCloseAllSlots(void) {
* Cluster state evaluation function
* -------------------------------------------------------------------------- */

const char *getClusterFailReasonString(void) {
switch (server.cluster->fail_reason) {
case CLUSTER_FAIL_NONE: return "none";
case CLUSTER_FAIL_NOT_FULL_COVERAGE: return "not-full-coverage";
case CLUSTER_FAIL_MINORITY_PARTITION: return "minority-partition";
default: serverPanic("Unknown fail reason code.");
}
}

void clusterLogFailReason(int reason) {
if (reason == CLUSTER_FAIL_NONE) return;

Expand Down Expand Up @@ -6105,7 +6096,6 @@ sds genClusterInfoString(void) {

info = sdscatprintf(info,
"cluster_state:%s\r\n"
"cluster_fail_reason:%s\r\n"
"cluster_slots_assigned:%d\r\n"
"cluster_slots_ok:%d\r\n"
"cluster_slots_pfail:%d\r\n"
Expand All @@ -6114,7 +6104,7 @@ sds genClusterInfoString(void) {
"cluster_size:%d\r\n"
"cluster_current_epoch:%llu\r\n"
"cluster_my_epoch:%llu\r\n",
statestr[server.cluster->state], getClusterFailReasonString(),
statestr[server.cluster->state],
slots_assigned, slots_ok, slots_pfail, slots_fail,
dictSize(server.cluster->nodes), server.cluster->size,
(unsigned long long)server.cluster->currentEpoch, (unsigned long long)nodeEpoch(myself));
Expand Down
28 changes: 7 additions & 21 deletions tests/unit/cluster/info.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,19 @@ start_cluster 3 0 {tags {external:skip cluster} overrides {cluster-node-timeout
pause_process [srv 0 pid]
wait_for_condition 1000 50 {
[CI 1 cluster_state] eq {fail} &&
[CI 2 cluster_state] eq {fail} &&
[CI 1 cluster_fail_reason] eq {not-full-coverage} &&
[CI 2 cluster_fail_reason] eq {not-full-coverage}
[CI 2 cluster_state] eq {fail}
} else {
fail "Cluster doesn't fail or the fail reason is not changed"
fail "Cluster doesn't fail"
}
verify_log_message -1 "*At least one hash slot is not served by any available node*" 0
verify_log_message -2 "*At least one hash slot is not served by any available node*" 0

# Kill one more primary, so the cluster fail with not-full-coverage.
# Kill one more primary, so the cluster fail with minority-partition.
pause_process [srv -1 pid]
wait_for_condition 1000 50 {
[CI 2 cluster_state] eq {fail} &&
[CI 2 cluster_fail_reason] eq {minority-partition}
} else {
fail "Cluster doesn't fail or the fail reason is not changed"
}
wait_for_log_messages -2 {"*minority partition*"} 0 1000 50

resume_process [srv 0 pid]
resume_process [srv -1 pid]
wait_for_condition 1000 50 {
[CI 0 cluster_state] eq {ok} &&
[CI 1 cluster_state] eq {ok} &&
[CI 2 cluster_state] eq {ok} &&
[CI 0 cluster_fail_reason] eq {none} &&
[CI 1 cluster_fail_reason] eq {none} &&
[CI 2 cluster_fail_reason] eq {none}
} else {
fail "Cluster doesn't stabilize"
}
wait_for_cluster_state ok
}
}

0 comments on commit d814cda

Please sign in to comment.