vertx-redis-client
vertx-redis-client copied to clipboard
Sentinel - Connection not being released on redis sentinel type
Version
4.2.5
Context
When connecting to redis using sentinel type, three connections are created:
- a connection with sentinel address to get the master address,
- a connection with the master address,
- another connection with sentinel address to watch for sentinel events (pub/sub connection).
The problem is happenning with the last one: it is being created as a pooled connection but it is a pub/sub connection. As result, it is not being released when RedisSentinelConnection.close()
is called and is kept open as long as the application stays alive.
Steps to reproduce
- Create a sentinel redis client API like below:
Vertx vertx = Vertx.vertx();
RedisOptions options = new RedisOptions().setType(RedisClientType.SENTINEL);
RedisAPI api = RedisAPI.api(Redis.createClient(vertx, options));
- Send a PING request through the API:
api.ping(List.of());
- You can notice that, for every request sent, a new connection is opened and not released. If you send requests periodically, after a certain period of time, it can reach the sentinel server
maxconnections
and hence starting reject connections.
vertx.setPeriodic(100, h -> api.ping(List.of()));
OS: Windows 10 64 bits JVM: open-jdk-11