jedis icon indicating copy to clipboard operation
jedis copied to clipboard

RedisCluster that can use ReadOnly slaves

Open digitalsonic opened this issue 6 years ago • 14 comments

JedisCluster uses only Master nodes in the cluster, all the Slave nodes are only standby nodes. In many situation this is a waste of resources.

So I write an EnhancedJedisClusterInfoCache besides the original JedisClusterInfoCache. When we want to read only from Master, JedisCluster will use JedisClusterInfoCache, nearly nothing changed. But if we want to read from Slave or both Master and Slave nodes, JedisClusterConnectionHandler will create an EnhancedJedisClusterInfoCache.

In the new cache class, there are two maps, one for master nodes and the other for slave nodes. All the Jedis instances in the slave pool have been sent a ReadOnly command when they were created.

When renewing the slot cache (master goes down or slot migration), both of the two maps will be reset, the JedisPool will be destroyed. So we don't need to worry about writing to a ReadOnly node.

Thanks for reviewing my codes.

P.S. I've read #790 #830 and some other posts and issues about ReadOnly slaves. And my thought is definitely same with @marcosnils mentioned in #1522 .

digitalsonic avatar Mar 15 '18 16:03 digitalsonic

Got all code up & running. Looking forward to this getting merged!

phenomax avatar Mar 26 '18 18:03 phenomax

Can anybody else review this PR? @marcosnils @sazzad16 can you help? Thank you.

digitalsonic avatar May 03 '18 15:05 digitalsonic

@digitalsonic when is this going to be merged?

venkatrangan avatar Jul 30 '18 17:07 venkatrangan

@venkatrangan sorry, i don't know, either.

digitalsonic avatar Aug 05 '18 16:08 digitalsonic

great pr!when it can be merged and release!

darren-fu avatar Feb 03 '19 02:02 darren-fu

Any plans on merging this?

angelim avatar Aug 02 '19 00:08 angelim

Any plan for merging this?

chandresh-pancholi avatar Feb 06 '20 07:02 chandresh-pancholi

Any plan for merging this?

Kate-liu avatar Jun 24 '20 16:06 Kate-liu

Any plan for merging this?

OneCodeMonkey avatar Jul 14 '21 14:07 OneCodeMonkey

To everyone who have asked about merging this PR, first of all I thank you all for your interest in Jedis.

This PR has a few backward incompatible parts which wouldn't allow a smooth transition from one version to another for the users who have codes based on the concerned classes. So this specific PR is unlikely to be merged.

We have kept open this PR hoping that someone would pick-up the idea and craft another PR with not so backward incompatible parts or at least with "salvageable" ones.

Thanks again.

sazzad16 avatar Jul 23 '21 18:07 sazzad16

@sazzad16 can you please elaborate more on backward-incompatible changes? I've spotted only JedisClusterConnectionHandler. Since this was introduced before v4.x, is there an existing way already to be able to read from replicas in readonly mode?

Btw looks like by PR JedisCluster / BinaryJedisCluster / JedisClusterConnectionHandler / JedisFactory require using builder pattern for extendibility, which will require.. a breaking change

eugeniyk avatar Dec 16 '22 23:12 eugeniyk

@sazzad16 can you please elaborate more on backward-incompatible changes? That way I could try to offer a new PR with less breaking changes. Thanks!

esigma5 avatar May 09 '23 18:05 esigma5

@esigma5 @eugeniyk Just try not to remove too many public methods and public classes and/or change their behavior with current parameters.

PS: We have started publishing alpha releases for Jedis 5.0. Now is a very good time to work on things that may have breaking parts. Also, if you have something promising please let us know, preferably as WIP or POC, in case we want to wait.

@eugeniyk Sincere apologies I missed your comment above.

sazzad16 avatar May 10 '23 15:05 sazzad16

any news? waiting for it

shiranyosef1 avatar Nov 18 '23 21:11 shiranyosef1