vertx-redis-client icon indicating copy to clipboard operation
vertx-redis-client copied to clipboard

Sentinel - Connection not being released on redis sentinel type

Open victorgawk opened this issue 2 years ago • 0 comments

Version

4.2.5

Context

When connecting to redis using sentinel type, three connections are created:

  1. a connection with sentinel address to get the master address,
  2. a connection with the master address,
  3. 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

  1. 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));

  1. Send a PING request through the API:

api.ping(List.of());

  1. 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

victorgawk avatar Mar 13 '22 17:03 victorgawk