You can't write against a read only replica

957 views
Skip to first unread message

Ankit Gupta

unread,
Dec 14, 2021, 8:37:45 AM12/14/21
to Redis DB
Hi Experts,

We are using redis version 5.x, and using sentinel based architecture.

Below is the setup

                              N1(M)
                              /         \
                            /             \
                         N2(S)         N3(S)

N1 got crashed  , and due to failover N3 was promoted as a new master. After sometime when N1 was recovered & joined the setup/cluster as slave it requested for a full re-synchronization from N3(present master) due to which BGSave was invoked. 

During this process any request on master , was giving below error:

org.springframework.data.redis.connection.RedisPipelineException: Pipeline contained one or more invalid commands; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: READONLY You can't write against a read only replica.; nested exception is redis.clients.jedis.exceptions.JedisDataException: READONLY You can't write against a read only replica.

We have few queries around this
1. Are we getting this error because master was busy in serving any other request?
2. Is there a configuration we can do so that if another slave is already connected then new node should do sync from existing slave?
3. Is this the expected behaviour?

Thanks in advance.

-Ankit



Vivek Mishra

unread,
Jul 22, 2022, 4:13:25 PMJul 22
to Redis DB



In my case i set REDIS_HOST to the service redis-headless and it worked

Ankit Gupta

unread,
Aug 28, 2022, 10:46:54 AMAug 28
to Redis DB
Hi All, 

We received this error again in our production setup.  Surprisingly there's nothing revealed in the redis.log or even in sentinel.log.  

If someone has someone faced similar issue, then you're help on this much appreciated.

Ankit Gupta

unread,
Aug 28, 2022, 10:48:00 AMAug 28
to Redis DB
Hi Vivek,

Has the issue resolved after this fix ?

Can you please share the steps that you followed for this ?


On Saturday, July 23, 2022 at 1:43:25 AM UTC+5:30 Vivek Mishra wrote:

Ankit Gupta

unread,
Sep 5, 2022, 1:19:59 AMSep 5
to Redis DB
Hi Team,

Has anyone faced such an issue. Can this be an issue with # of connections or sentinel overload or client library ?

Reply all
Reply to author
Forward
0 new messages