• antirez's avatar
    Cluster: fix memory leak of cached master. · 1a9e70c1
    antirez authored
    This is what happened:
    
    1. Instance starts, is a slave in the cluster configuration, but
    actually server.masterhost is not set, so technically the instance
    is acting like a master.
    
    2. loadDataFromDisk() calls replicationCacheMasterUsingMyself() even if
    the instance is a master, in the case it is logically a slave and the
    cluster is enabled. So now we have a cached master even if the instance
    is practically configured as a master (from the POV of
    server.masterhost value and so forth).
    
    3. clusterCron() sees that the instance requires to replicate from its
    master, because logically it is a slave, so it calls
    replicationSetMaster() that will in turn call
    replicationCacheMasterUsingMyself(): before this commit, this call would
    overwrite the old cached master, creating a memory leak.
    1a9e70c1
replication.c 112 KB