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

Force sync on exit regardless how long replication was running #436

Open
hifi opened this issue Oct 3, 2022 · 0 comments
Open

Force sync on exit regardless how long replication was running #436

hifi opened this issue Oct 3, 2022 · 0 comments

Comments

@hifi
Copy link
Collaborator

hifi commented Oct 3, 2022

Sync on exit isn't very robust on v0.3.9 or current main. If the replication is signaled immediately or the exec command terminates very quickly it's possible the database connection is never initialized and will never perform the final sync since it wasn't yet open. This is mainly possible because the connection is lazily initialized during the db Sync() call making the opening a bit racy and the close handler avoiding final sync if the database wasn't open.

This is easily reproducible by a command line like this:

litestream replicate -exec /bin/true

To make it succeed you can use a process that hangs around a little longer depending on replication target initialization speed:

litestream replicate -exec 'sleep 1'`

We're using this to force a one off sync where we'd like the Litestream exit code to be non-zero if there's any issues with the replication target so we can hold off any operations that depend on successful replication outside normal operation.

hifi added a commit to beeper/litestream that referenced this issue Oct 4, 2022
hifi added a commit to beeper/litestream that referenced this issue Apr 26, 2023
hifi added a commit to beeper/litestream that referenced this issue Apr 26, 2023
hifi added a commit to beeper/litestream that referenced this issue May 1, 2023
hifi added a commit to beeper/litestream that referenced this issue May 7, 2023
athoscouto pushed a commit to chiselstrike/litestream that referenced this issue May 30, 2023
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

No branches or pull requests

1 participant