GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
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.
add FailSafe implementation
Isn't this accomplishing the same thing as Redis Sentinel?...master failover?
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.
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.
simplify and fix bug in FailSafe implementation
@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
@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: https://github.com/hamsterready/jedis-sentinel-pool
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).
@FelixGV, the implementation that @huy did does not use Redis Sentinel, it's uses another approach.
@mardambey , you code is released?
Jedis supports Sentinel now. So for now I'm closing this issue.