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

Strict repository lock handling #3569

Merged
merged 11 commits into from
Oct 2, 2022

Commits on Oct 2, 2022

  1. Remove unnecessary context.WithCancel calls

    The gopts.ctx is cancelled when the main() method of restic exits.
    MichaelEischer committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    d0668b6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ab819b2 View commit details
    Browse the repository at this point in the history
  3. Remove ctx from globalOptions

    Previously the global context was either accessed via gopts.ctx,
    stored in a local variable and then used within that function or
    sometimes both. This makes it very hard to follow which ctx or a wrapped
    version of it reaches which method.
    
    Thus just drop the context from the globalOptions struct and pass it
    explicitly to every command line handler method.
    MichaelEischer committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    985722b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    928914f View commit details
    Browse the repository at this point in the history
  5. lock: Implement strict lock expiry monitoring

    Restic continued e.g. a backup task even when it failed to renew the
    lock or failed to do so in time. For example if a backup client enters
    standby during the backup this can allow other operations like `prune`
    to run in the meantime (after calling `unlock`). After leaving standby
    the backup client will continue its backup and upload indexes which
    refer pack files that were removed in the meantime.
    
    This commit introduces a goroutine explicitly monitoring for locks that
    are not refreshed in time. To simplify the implementation there's now a
    separate goroutine to refresh the lock and monitor for timeouts for each
    lock. The monitoring goroutine would now cause the backup to fail as the
    client has lost it's lock in the meantime.
    
    The lock refresh goroutines are bound to the context used to lock the
    repository initially. The context returned by `lockRepo` is also
    cancelled when any of the goroutines exits. This ensures that the
    context is cancelled whenever for any reason the lock is no longer
    refreshed.
    MichaelEischer committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    d92957d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c3538b0 View commit details
    Browse the repository at this point in the history
  7. lock: Add integration test

    The tests check that the wrapped context is properly canceled whenever
    the repository is unlock or when the lock refresh fails.
    MichaelEischer committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    9959190 View commit details
    Browse the repository at this point in the history
  8. add changelog

    MichaelEischer committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    aeed420 View commit details
    Browse the repository at this point in the history
  9. lock: Do not ignore invalid lock files

    While searching for lock file from concurrently running restic
    instances, restic ignored unreadable lock files. These can either be
    in fact invalid or just be temporarily unreadable. As it is not really
    possible to differentiate between both cases, just err on the side of
    caution and consider the repository as already locked.
    
    The code retries searching for other locks up to three times to smooth
    out temporarily unreadable lock files.
    MichaelEischer committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    401e432 View commit details
    Browse the repository at this point in the history
  10. lock: fix timer expiry monitoring during standby

    Monotonic timers are paused during standby. Thus these timers won't fire
    after waking up. Fall back to periodic polling to detect too large clock
    jumps. See golang/go#35012 for a discussion of
    go timers during standby.
    MichaelEischer committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    4912679 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    6d2d297 View commit details
    Browse the repository at this point in the history