redis / jedis

Redis Java client
MIT License
11.77k stars 3.86k forks source link

Sleeping time not configurable when reconnecting to Sentinel #2864

Open barbasa opened 2 years ago

barbasa commented 2 years ago

Expected behavior

JedisSentinelPool listen to the master messages via a MasterListener. If a connection with a Sentinel is lost, the listener tries to reconnect after a configurable sleeping time.

This can be an issue when several clients get disconnected together. When they will try to re-connect, all of them after 5000ms, to Redis they will create a spike in new connections.

Adding a random factor to the sleeping value, or making it configurable so that the user can define it randomly, would avoid the spike.

Actual behavior

The retry time is hardcoded to 5000ms.

Steps to reproduce:

  1. Setup a Redis cluster using Sentinels
  2. Connect the Santinels in your app
  3. Stop your sentinels
  4. Check the logs. In the logs there will be a message like: "Lost connection to Sentinel at . Sleeping 5000ms and retrying"

The 5000ms is not configgurable.

Redis / Jedis Configuration

Jedis version: 2.10.2

Redis version: 6.2

Java version: 11

sazzad16 commented 2 years ago

Yes, the sleep time is not configurable. We welcome a PR.

@barbasa Apologies for late reply.

github-actions[bot] commented 8 months ago

This issue is marked stale. It will be closed in 30 days if it is not updated.