Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added single Redis instance Redlock support. #32

Closed
wants to merge 6 commits into from

Commits on Oct 30, 2019

  1. Added single Redis instance Redlock support.

    The definition of the Redlock (template) class is available in
    src/sw/redis++/redlock.*
    
    The tests are implemented in test/src/sw/redis++/redlock_test.h*
    
    The implementation is meant for a single Redis instance or for a
    single clustered Redis instance. The locking of multiple instances is
    not supported, but could be added.
    wingunder committed Oct 30, 2019
    Configuration menu
    Copy the full SHA
    7602669 View commit details
    Browse the repository at this point in the history
  2. Use pexpire instead of expire in the extendLockScript.

    Thanks to sewenew for pointing this out.
    
    Another test case was added to cover this situation.
    wingunder committed Oct 30, 2019
    Configuration menu
    Copy the full SHA
    7ebc11f View commit details
    Browse the repository at this point in the history
  3. Increased the TTL in the redlock tests, as some test failed sometimes.

    The problem is that Redis is not really spot on with removing timed
    out keys. This means that a key might still be around a few
    milliseconds after it should have expired.
    
    The test TTL is now 200ms.
    wingunder committed Oct 30, 2019
    Configuration menu
    Copy the full SHA
    a082394 View commit details
    Browse the repository at this point in the history
  4. The Redlock destructor now unlocks all remaining locks.

    Thanks to sewenew for giving me this idea.
    wingunder committed Oct 30, 2019
    Configuration menu
    Copy the full SHA
    253df44 View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2019

  1. Fixed the timing in the Redlock::extend_lock() test.

    We now allow 2 ms for latency:
       - 1 ms for extend_lock()
       - 1 ms for Redis expire latency.
    wingunder committed Oct 31, 2019
    Configuration menu
    Copy the full SHA
    d6cbd18 View commit details
    Browse the repository at this point in the history
  2. Redlock: Avoid calling 'EXISTS' before every 'EVALSHA'.

    We now just call 'EVALSHA' and if it fails in cluster mode, we assume
    that the key moved to a node that has not got the script loaded
    yet. In this case we simply load the script and call 'EVALSHA' again.
    wingunder committed Oct 31, 2019
    Configuration menu
    Copy the full SHA
    7a0a696 View commit details
    Browse the repository at this point in the history