add FailSafe implementation #386

wants to merge 2 commits into


None yet
7 participants

huy commented Jan 24, 2013


I have added a simple implementation of Fail Safe Jedis that can detect if Redis Master fails or has been changed and gracefully switch to the new Master (if there is any) in the context of Redis Master/Slave replication cluster.

We are using this code in one of our project, so if you feel that it is useful for community please incorporate it into master branch.

I had an intention to do some refactor to reduce a bit of duplication and rewrite sharding implementation to allow combine sharding with fail safe features but don´t want to touch the original code base without knowing your opinion first.

jmlogan commented Jan 24, 2013

Isn't this accomplishing the same thing as Redis Sentinel?...master failover?

huy commented Jan 24, 2013

It is complementary to Redis Sentinel. Sentinel will elect new master and reset cluster to the new elected master in case that the original master fails, however client has to reconnect to new master. This commit implement client reconnection.

jmlogan commented Jan 24, 2013

I believe there was a pull request about Sentinel, that would let you use a pool, and automatically reconnect...if I recall, it wasn't merged yet though.

FelixGV commented Aug 19, 2013

@jmlogan, @huy, do you have any news on this work?

Is this pull request eventually going to make it into master? Or has it been superseded by some other PR that @jmlogan was mentioning?

We are looking for an automatic fail-over solution for jedis clients. We are, of course, fully prepared to do the necessary testing to make sure that fail-over works properly in our environment, but settling on a single official community-backed solution would be preferable for everyone, IMHO.


Is it this pull request that you are talking about? I thought it was merged. #370


mardambey commented Aug 21, 2013

@Dao007forever, actually, no, #370 just adds support for Sentinel commands, it does not subscribe to master changes that are published by Sentinels allowing Jedis to reconnect to the new master.

There's a Jedis pool with Sentinel support here:

However it does not work with Jedis since the Pool object in Jedis, which the Sentinel pool extends, does not have an public empty constructor (it's protected now). The Pool has to be changed such that it does not need the internal connection pool to be created on construction time (since Sentinel needs to discover the master first, then connect to it).

I'm in the process of doing this work at the moment and if it ends up being useful and the changes make sense I'll make it public in the next few days (it is currently part of an internal project we're working on, I want to split the Sentinel part outside the project and make it available on its own, I can make it part of Jedis itself except I'm depending on Akka right now and I don't think people would appreciate pulling down Akka if they want to use Jedis).


mardambey commented Aug 22, 2013

@FelixGV, the implementation that @huy did does not use Redis Sentinel, it's uses another approach.

@mardambey , you code is released?


HeartSaVioR commented May 31, 2015

Jedis supports Sentinel now. So for now I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment