Skip to content

Improve expire consistency on slaves #1768

Closed

Description

@antirez

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:

  • expireIfNeeded() in the context of slaves don't really try to evict expired keys, but just returns a return-value to signal if the key should be expired according to our local clock.
  • server.current_client could be used in order to test if the current client is our master.

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.

Activity

  1. antirez commented on Dec 10, 2014

    @antirez
    ContributorAuthor

    Fixed in 06e76bc.

  2. mangatmodi commented on Oct 1, 2015

    @mangatmodi

    I just checked that the issue persists on 3.04(stable) version. Checked the source, patch was never merged. Just wondering if we are actually planning to resolve the issue. Logically slaves are not consistent with master which is quite dangerous.

  3. sirdawidd commented on Oct 27, 2015

    @sirdawidd

    There is some chance that it will be merged?

  4. antirez commented on Oct 27, 2015

    @antirez
    ContributorAuthor

    Hello, it was merged in the context of Redis 3.2 that will go RC before end of the year. No way we can put this into 3.0, too big semantical change. Thanks.

  5. antirez commented on Oct 27, 2015

    @antirez
    ContributorAuthor

    p.s. Redis 3.2 branch name is testing.

  6. zagfai commented on Aug 15, 2016

    @zagfai

    Yes a big problem with limit explanation on documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions