Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve expire consistency on slaves #1768
In order for Redis to ensure consistency between a master and its slaves, eviction of keys with an expire are managed by the master, which sends an explicit DEL to its slaves when the key gets actually removed.
This means that slaves are not able to directly expire keys, even if these keys are logically expired on the master side. So a GET that will return null in the master side, may return a stale value in the slave side.
This is a limit when using slaves in order to scale reads. Also the behavior does not require to be as global as it is currently. Normally slaves are configured in a read-only fashion, so they can only accept read commands from normal clients, and write commands from the master.
lookupKeyRead() may be modified in order to return NULL in the context of a slave, if the current client is not the master, even if it will not actually evict the key from the key space.
To implement this we could resort to two APIs:
A more in depth analysis is needed, but likely just using this simple checks we could be able to have a more sane semantics of read commands on slaves in a safe way.