diff options
author | Viktor Söderqvist <viktor.soderqvist@est.tech> | 2022-09-14 02:48:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 17:48:48 -0700 |
commit | 42e4241ecee472fc2341660e29652f0e2a485453 (patch) | |
tree | 5311dc35aff217db6cc46a5c3a688af0e9b2a580 /src | |
parent | 6c03786b66d27a53629cac21d5b89b17bfad6b65 (diff) | |
download | redis-42e4241ecee472fc2341660e29652f0e2a485453.tar.gz |
Avoid crash when a cluster node is a replica of a replica of itself (#11263)
Diffstat (limited to 'src')
-rw-r--r-- | src/cluster.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cluster.c b/src/cluster.c index 862c3c572..3a419f9d4 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1977,7 +1977,13 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG| CLUSTER_TODO_UPDATE_STATE| CLUSTER_TODO_FSYNC_CONFIG); - } else if (myself->slaveof && myself->slaveof->slaveof) { + } else if (myself->slaveof && myself->slaveof->slaveof && + /* In some rare case when CLUSTER FAILOVER TAKEOVER is used, it + * can happen that myself is a replica of a replica of myself. If + * this happens, we do nothing to avoid a crash and wait for the + * admin to repair the cluster. */ + myself->slaveof->slaveof != myself) + { /* Safeguard against sub-replicas. A replica's master can turn itself * into a replica if its last slot is removed. If no other node takes * over the slot, there is nothing else to trigger replica migration. */ |