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

Add a global option --retry-lock #4107

Merged
merged 3 commits into from Apr 11, 2023

Conversation

jooola
Copy link
Contributor

@jooola jooola commented Dec 28, 2022

Attempt to resurrect #2214

What does this PR change? What problem does it solve?

If the option is passed, restic will wait the specified duration of time and retry locking the repo every 10 seconds (or more often if the total timeout is relatively small).

Was the change previously discussed in an issue or on the forum?

Fixes #719

Checklist

  • I have read the contribution guidelines.
  • I have enabled maintainer edits.
  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I have run gofmt on the code in all commits.
  • All commit messages are formatted in the same style as the other commits in the repo.
  • I'm done! This pull request is ready for review.

Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR needs a few more tweaks, but it's already in a good shape.

cmd/restic/lock.go Outdated Show resolved Hide resolved
cmd/restic/lock.go Outdated Show resolved Hide resolved
cmd/restic/lock.go Outdated Show resolved Hide resolved
cmd/restic/lock_test.go Outdated Show resolved Hide resolved
cmd/restic/lock_test.go Outdated Show resolved Hide resolved
@jooola jooola force-pushed the feature-wait-for-unlock branch 2 times, most recently from 790e4b4 to 8121549 Compare February 16, 2023 17:18
Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please squash the commits.

I wonder whether the timing checks in the tests might be too strict or not. But we can fix that if it turns out to be a problem.

Fixes restic#719

If the option is passed, restic will wait the specified duration of time
and retry locking the repo every 10 seconds (or more often if the total
timeout is relatively small).

- Play nice with json output
- Reduce wait time in lock tests
- Rework timeout last attempt
- Reduce test wait time to 0.1s
- Use exponential back off for the retry lock
- Don't pass gopts to lockRepo functions
- Use global variable for retry sleep setup
- Exit retry lock on cancel
- Better wording for flag help
- Reorder debug statement
- Refactor tests
- Lower max sleep time to 1m
- Test that we cancel/timeout in time
- Use non blocking sleep function
- Refactor into minDuration func

Co-authored-by: Julian Brost <julian@0x4a42.net>
@jooola
Copy link
Contributor Author

jooola commented Apr 7, 2023

  • Rebased onto the master branch
  • Squashed the PR history into the first commit

@MichaelEischer
Copy link
Member

Hmm, it looks like the durations checks are too strict:
https://github.com/restic/restic/actions/runs/4638924198/jobs/8211940279?pr=4107
https://github.com/restic/restic/actions/runs/4638924198/jobs/8211506876?pr=4107

I've broadened them quite a bit, but I fear these might become another TestLockSuccessfulRefresh which fails far too often.

@MichaelEischer MichaelEischer merged commit 2091fc0 into restic:master Apr 11, 2023
11 checks passed
@jooola jooola deleted the feature-wait-for-unlock branch April 21, 2023 09:26
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.

Make restic wait when locked
2 participants