• antirez's avatar
    Slaves heartbeat while loading RDB files. · 27db38d0
    antirez authored
    Starting with Redis 2.8 masters are able to detect timed out slaves,
    while before 2.8 only slaves were able to detect a timed out master.
    
    Now that timeout detection is bi-directional the following problem
    happens as described "in the field" by issue #1449:
    
    1) Master and slave setup with big dataset.
    2) Slave performs the first synchronization, or a full sync
       after a failed partial resync.
    3) Master sends the RDB payload to the slave.
    4) Slave loads this payload.
    5) Master detects the slave as timed out since does not receive back the
       REPLCONF ACK acknowledges.
    
    Here the problem is that the master has no way to know how much the
    slave will take to load the RDB file in memory. The obvious solution is
    to use a greater replication timeout setting, but this is a shame since
    for the 0.1% of operation time we are forced to use a timeout that is
    not what is suited for 99.9% of operation time.
    
    This commit tries to fix this problem with a solution that is a bit of
    an hack, but that modifies little of the replication internals, in order
    to be back ported to 2.8 safely.
    
    During the RDB loading time, we send the master newlines to avoid
    being sensed as timed out. This is the same that the master already does
    while saving the RDB file to still signal its presence to the slave.
    
    The single newline is used because:
    
    1) It can't desync the protocol, as it is only transmitted all or
    nothing.
    2) It can be safely sent while we don't have a client structure for the
    master or in similar situations just with write(2).
    27db38d0
networking.c 53.6 KB