Fixed - update new master record in DNS monitor only if it replaced old master successfully. #3104

pull/3209/head
Nikita Koksharov 4 years ago
parent 6ca346435e
commit c93865259f

@ -127,8 +127,13 @@ public class DNSMonitor {
log.error("Unable to find entry for current master {}", currentMasterAddr);
return;
}
masterSlaveEntry.changeMaster(newMasterAddr, entry.getKey());
masters.put(entry.getKey(), newMasterAddr);
RFuture<RedisClient> changeFuture = masterSlaveEntry.changeMaster(newMasterAddr, entry.getKey());
changeFuture.onComplete((r, e) -> {
if (e == null) {
masters.put(entry.getKey(), newMasterAddr);
}
});
}
}
});

@ -426,10 +426,11 @@ public class MasterSlaveEntry {
return future;
}
public void changeMaster(InetSocketAddress address, RedisURI uri) {
public RFuture<RedisClient> changeMaster(InetSocketAddress address, RedisURI uri) {
ClientConnectionsEntry oldMaster = masterEntry;
RFuture<RedisClient> future = setupMasterEntry(address, uri);
changeMaster(uri, oldMaster, future);
return future;
}

Loading…
Cancel
Save