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

"Implementing Reconnect on Error" example in README causes a connection leak

Open koby08 opened this issue 5 years ago • 1 comments

Hi,

It seems that the "Implementing Reconnect on Error" section in the official docs for this client contains a bad example. If someone runs this example, each time it reconnects, the old connection will remain open. This will cause a connection leak to redis server.

The reason for this leak is that in each reconnect attempt Redis.createClient() is called, but without closing the old one. Please notice that calling client.close() won't help as well, because it is an instance of a connection from the connection pool.

In order to fix this, you need to call close() on the instance returned from Redis.createClient() - which will close the connection pool.

koby08 avatar Oct 13 '20 14:10 koby08

Actually another issue with the current implementation is if there are several in-flight requests to Redis, and all fire an exception due to some failure, there will be multiple connection attempts that will create dangling clients

koby08 avatar Oct 13 '20 14:10 koby08