• antirez's avatar
    PSYNC2: Fix the way replication info is saved/loaded from RDB. · c1c99e9f
    antirez authored
    This commit attempts to fix a number of bugs reported in #4316.
    They are related to the way replication info like replication ID,
    offsets, and currently selected DB in the master client, are stored
    and loaded by Redis. In order to avoid inconsistencies the changes in
    this commit try to enforce that:
    
    1. Replication information are only stored when the RDB file is
    generated by a slave that has a valid 'master' client, so that we can
    always extract the currently selected DB.
    2. When replication informations are persisted in the RDB file, all the
    info for a successful PSYNC or nothing is persisted.
    3. The RDB replication informations are only loaded if the instance is
    configured as a slave, otherwise a master can start with IDs that relate
    to a different history of the data set, and stil retain such IDs in the
    future while receiving unrelated writes.
    c1c99e9f
replication.c 106 KB