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
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d6cbd18cd7b64c40d2fbb34b9e061f13d8b5969a
5 changes: 3 additions & 2 deletions test/src/sw/redis++/redlock_test.hpp
Original file line number Diff line number Diff line change
@@ -170,8 +170,9 @@ void RedlockTest<RedisInstance>::run() {
usleep(ttl.count() * 1000 * 2 / 3);
// Now we have 1/3 of the ttl left, so we extend it by ttl.
if (redLock.extend_lock(lockKey, ttl)) {
// We'll sleep ttl + 100 millis and see if the lock is gone.
usleep((ttl.count() * 1000) + 100);
// We'll sleep ttl + 2 millis and see if the lock is gone.
// 1 ms for extend_lock() and 1 ms for Redis expire latency.
usleep((ttl.count() + 2) * 1000);
// Locking it should not fail.
if (redLock.lock(lockKey, ttl)) {
redLock.unlock(lockKey);