• Steve's avatar
    Avoid cluster.nodes load corruption due to shard-id generation (#13468) · d265a614
    Steve authored
    
    
    PR #13428 doesn't fully resolve an issue where corruption errors can
    still occur on loading of cluster.nodes file - seen on upgrade where
    there were no shard_ids (from old Redis), 7.2.5 loading generated new
    random ones, and persisted them to the file before gossip/handshake
    could propagate the correct ones (or some other nodes unreachable).
    This results in a primary/replica having differing shard_id in the
    cluster.nodes and then the server cannot startup - reports corruption.
    
    This PR builds on #13428 by simply ignoring the replica's shard_id in
    cluster.nodes (if it exists), and uses the replica's primary's shard_id.
    Additional handling was necessary to cover the case where the replica
    appears before the primary in cluster.nodes, where it will first use a
    generated shard_id for the primary, and then correct after it loads the
    primary cluster.nodes entry.
    
    ---------
    Co-authored-by: default avatardebing.sun <debing.sun@redis.com>
    d265a614
cluster_legacy.c 256 KB