mzafer
mzafer

Reputation: 851

Redis SLAVE flushes data when MASTER goes down

I have commented the "save" commands in both my master and slave as I want to do only in memory caching and not persist to the file. This works fine but as soon as the Master goes down and before Slave can be promoted to master ( It actually freezes for a min ) it starts flushing the data. How can I prevent the slave from flushing the data.

Thanks zafer

Upvotes: 2

Views: 2300

Answers (1)

Didier Spezia
Didier Spezia

Reputation: 73306

Actually, the slave does not flush the data when the master goes down.

It starts a SYNC (flushing the data before) with the master, when it has lost the connection with the master, and has established the connection again.

IMO, the problem is the master restarts immediately, so the slave can reconnect before it has been promoted to master.

You should delay the restart of the master until the slave have been promoted. Depending on how the HA is automated, it may not be very convenient. A simple (but not very reliable) solution is to just put a delay in the start script of the Redis instance. The delay should be calculated so that you are 100% sure the slave will be promoted before it times out. A more complex solution is to try to connect to the slave in the start script of the master, and run the INFO command to check its status, before allowing the start.

See the following discussion for more information:

https://groups.google.com/d/topic/redis-db/wmRSuIgHcEs/discussion

Upvotes: 1

Related Questions