Fixed - connection is closed per command execution for master node used as slave in readMode = MASTER_SLAVE #1550

pull/1552/head
Nikita 7 years ago
parent 543835607e
commit fe49988f2a

@ -25,6 +25,7 @@ import org.redisson.client.RedisClient;
import org.redisson.client.RedisConnection;
import org.redisson.client.RedisPubSubConnection;
import org.redisson.config.MasterSlaveServersConfig;
import org.redisson.config.ReadMode;
import org.redisson.pubsub.AsyncSemaphore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -73,6 +74,10 @@ public class ClientConnectionsEntry {
connectionManager.getConnectionWatcher().add(poolMinSize, poolMaxSize, freeConnections, freeConnectionsCounter);
}
public boolean isMasterForRead() {
return getFreezeReason() == FreezeReason.SYSTEM && getConfig().getReadMode() == ReadMode.MASTER_SLAVE;
}
public void setNodeType(NodeType nodeType) {
this.nodeType = nodeType;
}

@ -29,7 +29,6 @@ import org.redisson.client.RedisConnectionException;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.config.MasterSlaveServersConfig;
import org.redisson.config.ReadMode;
import org.redisson.connection.ClientConnectionsEntry;
import org.redisson.connection.ClientConnectionsEntry.FreezeReason;
import org.redisson.connection.ConnectionManager;
@ -168,8 +167,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
List<ClientConnectionsEntry> entriesCopy = new LinkedList<ClientConnectionsEntry>(entries);
while (!entriesCopy.isEmpty()) {
ClientConnectionsEntry entry = config.getLoadBalancer().getEntry(entriesCopy);
if ((!entry.isFreezed() ||
(entry.getFreezeReason() == FreezeReason.SYSTEM && config.getReadMode() == ReadMode.MASTER_SLAVE)) &&
if ((!entry.isFreezed() || entry.isMasterForRead()) &&
tryAcquireConnection(entry)) {
return acquireConnection(command, entry);
}
@ -421,7 +419,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
}
public void returnConnection(ClientConnectionsEntry entry, T connection) {
if (entry.isFreezed()) {
if (entry.isFreezed() && !entry.isMasterForRead()) {
connection.closeAsync();
} else {
releaseConnection(entry, connection);

Loading…
Cancel
Save