-
Notifications
You must be signed in to change notification settings - Fork 283
Leasing (S3) #617
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
Draft
benbjohnson
wants to merge
1
commit into
main
Choose a base branch
from
s3-lease
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Leasing (S3) #617
+1,004
−123
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Out of curiosity, is there a way to avoid missing writes on the database B in a rolling restart scenario? Let's say my restart procedure is: 1. Restore db, 2. Wait for replication to begin, 3. Start my application. While leasing solves the multiple writers issue in step 2, the local copy of the db will miss any writes that went to the prior deployment between the first two steps, right? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This pull request adds optional leasing to Litestream to allow it to run in ephemeral environments that don't have a persistent disk. This is implemented using conditional writes that are recently available in S3. Conditional writes have already been supported by some S3-compatible object stores such as Tigris Data.
How it works
Time-based leasing is a method of leader election that ensures that only one instance of Litestream is running at a time. On startup, a lease is acquired and continually renewed while the
litesteamprocess is running. If Litestream fails to renew a lease, it will exit the process immediately since it cannot safely backup.When another Litestream process starts up and sees an existing lease, it will continually retry the lease acquisition every second until it succeeds. This low retry interval allows for rolling restarts to come online quickly.
If Litestream exits normally then it will release the lease it had previously acquired and another process will be able to take over immediately. If Litestream has an unexpected exit then the lease will continue to exist until the timeout is reached. The lease timeout defaults to 30 seconds.
Usage
To enable leasing, configure it in your
litestream.ymlfile:The path of the URL (e.g.
/lease) is the coordination point so any other Litestream processes will block if they are started with the same bucket & path and another process has already acquired the lease.