Fixed - MASTER nodes isn't used in readMode = MASTER_SLAVE. #5723

pull/5763/head^2
Nikita Koksharov 10 months ago
parent 333d4274b2
commit 1d8278ac06

@ -531,7 +531,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
if (v) {
log.info("slave: {} is up for slot ranges: {}", uri, currentPart.getSlotRanges());
currentPart.removeFailedSlaveAddress(uri);
return entry.excludeMasterFromSlaves(uri);
entry.excludeMasterFromSlaves(uri);
}
return v;
});
@ -578,7 +578,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
if (v) {
currentPart.addSlaveAddress(uri);
log.info("slave: {} added for slot ranges: {}", uri, currentPart.getSlotRanges());
return entry.excludeMasterFromSlaves(uri);
entry.excludeMasterFromSlaves(uri);
}
return v;
});

@ -106,7 +106,8 @@ public class MasterSlaveEntry {
}
private void useMasterAsSlave() {
if (hasNoSlaves()) {
if (hasNoSlaves()
|| config.getReadMode() == ReadMode.MASTER_SLAVE) {
addSlaveEntry(masterEntry);
} else {
removeSlaveEntry(masterEntry);
@ -434,7 +435,8 @@ public class MasterSlaveEntry {
CompletableFuture<Boolean> f = unfreezeAsync(entry, freezeReason);
return f.thenApply(r -> {
if (r) {
return excludeMasterFromSlaves(entry.getClient().getAddr());
excludeMasterFromSlaves(entry.getClient().getAddr());
return r;
}
return r;
});
@ -445,7 +447,8 @@ public class MasterSlaveEntry {
CompletableFuture<Boolean> f = unfreezeAsync(address, freezeReason);
return f.thenApply(r -> {
if (r) {
return excludeMasterFromSlaves(address);
excludeMasterFromSlaves(address);
return r;
}
return r;
});
@ -453,7 +456,8 @@ public class MasterSlaveEntry {
public boolean excludeMasterFromSlaves(RedisURI address) {
InetSocketAddress addr = masterEntry.getClient().getAddr();
if (address.equals(addr)) {
if (address.equals(addr)
|| config.getReadMode() == ReadMode.MASTER_SLAVE) {
return false;
}
@ -464,7 +468,8 @@ public class MasterSlaveEntry {
public boolean excludeMasterFromSlaves(InetSocketAddress address) {
InetSocketAddress addr = masterEntry.getClient().getAddr();
if (config.isSlaveNotUsed() || addr.equals(address)) {
if (config.isSlaveNotUsed() || addr.equals(address)
|| config.getReadMode() == ReadMode.MASTER_SLAVE) {
return false;
}
@ -488,7 +493,8 @@ public class MasterSlaveEntry {
CompletableFuture<Boolean> f = unfreezeAsync(address, freezeReason);
return f.thenApply(r -> {
if (r) {
return excludeMasterFromSlaves(address);
excludeMasterFromSlaves(address);
return r;
}
return r;
});

Loading…
Cancel
Save