Namoshek/laravel-redis-sentinel

Seeing LOADING Redis is loading the dataset in memory

Closed this issue · 6 comments

This happens when one of sentinels pods is recreated and it starts loading stuff from other instances.

I would say this case is pretty much the same as when instance become READONLY.
It should force reconnect to new master.
i.e. same logic as here:

if (Str::contains($exception->getMessage(), ['READONLY', "You can't write against a read only replica"])) {
but for "LOADING Redis is loading the dataset in memory"

Interesting. Is it normal behavior of Redis Sentinel that it promotes a node if its not usable (yet)?

I don't think it is promoted as master at the time of connection attempt. Most probably it just returns LOADING, because it is not even a READONLY yet. It would be logical. And this library just does not expect LOADING as a version of not usable connection.
At least I could not find any proof that it was promoted as master node.

Okay, I've looked into the Redis source code and it seems that LOADING is in fact interpreted as an acceptable status code to a PING, just like PONG and MASTERDOWN (source). I find this somewhat counterintuitive and don't think Redis Sentinel should advertise an unready Redis instance, but I guess there might be good reasons to do so anyway.

I've created a PR with some changes in #16. It contains some logic we use nowadays with a different kind of Redis connector (we actually use KeyDB with multiple active-active master nodes). Please have a look and give me feedback if this looks good to you.

Looks good, thanks.
Really appriciate you looking into it!

Alright, release as v0.2.1. Please let me know if this solves your problem. 👍

resolved in v0.2.1