Having writable replica in a Redis cluster

108 Views Asked by At

I have a Redis cluster setup. I have set the 'replica-read-only' to 'no' to make the replicas writable.

On performing any 'STORE' operation like 'ZRANGESTORE' or 'ZUNIONSTORE' on a replica node of the Cluster, I a getting MOVED exception. Is there any other configuration required to make a replica writable?

My use case for Writable replica -
I am trying to perform secondary indexing in Redis as per https://redis.io/docs/manual/patterns/indexes/.
For secondary indexing, I use commands like 'ZRANGESTORE', 'ZUNIONSTORE' and 'ZINTERSTORE', store the results in temporary keys. As there a multiple fields on which the data is indexed, there are multiple set commands('ZRANGESTORE', 'ZUNIONSTORE' and 'ZINTERSTORE') done in a transaction and I delete all the temporary keys used for storing intermediate results in the process in the same transaction. This works well in a single node Redis setup but now I want to use a Redis cluster instead of a single node.
I want to use the replica nodes to perform all the set(indexing) operations and use the primary node just for writing data, and hence, require the write('STORE') commands in the replica node.

I setup a cluster with 6 nodes(3 primary, each with 1 replica). Following is the nodes configuration -

enter image description here

I created a set on the nodes on a primary node(node on 8004 port) -

enter image description here

When I perform a 'ZUNIONSTORE' operation on its secondary node(i.e. node on 8001 port), i get MOVED exception -

enter image description here

Redis version -
Redis server v=7.0.11 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=44169fc7b347b8ec

0

There are 0 best solutions below