mirror of https://mirror.osredm.com/root/redis.git
Check shard_id pointer validity in updateShardId (#12538)
When connecting between a 7.0 and 7.2 cluster, the 7.0 cluster will not populate the shard_id field, which is expect on the 7.2 cluster. This is not intended behavior, as the 7.2 cluster is supposed to use a temporary shard_id while the node is in the upgrading state, but it wasn't being correctly set in this case.
This commit is contained in:
parent
044e29dd34
commit
a2046c1eb1
|
@ -938,13 +938,13 @@ static void updateAnnouncedHumanNodename(clusterNode *node, char *new) {
|
||||||
|
|
||||||
|
|
||||||
static void updateShardId(clusterNode *node, const char *shard_id) {
|
static void updateShardId(clusterNode *node, const char *shard_id) {
|
||||||
if (memcmp(node->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
|
if (shard_id && memcmp(node->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
|
||||||
clusterRemoveNodeFromShard(node);
|
clusterRemoveNodeFromShard(node);
|
||||||
memcpy(node->shard_id, shard_id, CLUSTER_NAMELEN);
|
memcpy(node->shard_id, shard_id, CLUSTER_NAMELEN);
|
||||||
clusterAddNodeToShard(shard_id, node);
|
clusterAddNodeToShard(shard_id, node);
|
||||||
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
|
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
|
||||||
}
|
}
|
||||||
if (myself != node && myself->slaveof == node) {
|
if (shard_id && myself != node && myself->slaveof == node) {
|
||||||
if (memcmp(myself->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
|
if (memcmp(myself->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
|
||||||
/* shard-id can diverge right after a rolling upgrade
|
/* shard-id can diverge right after a rolling upgrade
|
||||||
* from pre-7.2 releases */
|
* from pre-7.2 releases */
|
||||||
|
|
Loading…
Reference in New Issue