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

[Enhancement] Clock-insensitive leader lock #25

Merged
merged 2 commits into from
Mar 8, 2020

Conversation

lloydmeta
Copy link
Owner

@lloydmeta lloydmeta commented Mar 8, 2020

This updates the leader lock implementation so that it's no longer sensitive to
differences in system clock on Tasques servers.

It does this by making non-Leaders eagerly try to gain leadership after sleeping
for the leader lock period.

Changes:

  • In CHECKER mode: stashes the current leader lock document even if
    not leader, then waits for the leader lock lease period, and sets
    mode to USURPER
  • In USURPER mode: tries to jostle for leadership right away
    • If there is a conflict, then someone else is leader (in normal cases, this is
      likely existing leader); go into CHECKER mode and re-loop.
  • When writing the leader lock document, we now also write the leader lock
    lease period, which non-leaders will wait for before trying to USURP.
    This allows config changes for leader_lock_lease to be rolled out
    to servers incrementally without suddenly changing wait time on the original
    leader.

Credit:

https://aws.amazon.com/blogs/database/building-distributed-locks-with-the-dynamodb-lock-client/

This updates the leader lock implementation so that it's no longer sensitive to
differences in system clock on Tasques servers.

It does this by making non-Leaders eagerly try to gain leadership after sleeping
for the leader lock period.

Changes:

* In CHECKER mode: stashes the current leader lock document even if
  not leader, then *waits* for the leader lock lease period, and sets
  mode to USURPER
* In USURPER mode: tries to jostle for leadership right away
  * If there is a conflict, then someone else is leader (in normal cases, this is
    likely existing leader); go into CHECKER mode and re-loop.
* When writing the leader lock document, we now also write the leader lock
  lease period, which non-leaders will wait for before trying to USURP.
  This allows config changes for leader_lock_lease to be rolled out
  to servers incrementally without suddenly changing wait time on the original
  leader.

Signed-off-by: lloydmeta <[email protected]>
Signed-off-by: lloydmeta <[email protected]>
@codecov-io
Copy link

Codecov Report

Merging #25 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #25   +/-   ##
=======================================
  Coverage   83.97%   83.97%           
=======================================
  Files          18       18           
  Lines        1142     1142           
=======================================
  Hits          959      959           
  Misses        121      121           
  Partials       62       62

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abd3627...26e7ae1. Read the comment docs.

@lloydmeta lloydmeta merged commit 0a35df3 into master Mar 8, 2020
@lloydmeta lloydmeta deleted the enhance/clock-insensitive-leader-lock branch March 8, 2020 06:47
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants