Skip to content

prune: Better handling of eventually consistent backend#2685

Closed
MichaelEischer wants to merge 3 commits intorestic:masterfrom
MichaelEischer:prune-eventual-list
Closed

prune: Better handling of eventually consistent backend#2685
MichaelEischer wants to merge 3 commits intorestic:masterfrom
MichaelEischer:prune-eventual-list

Conversation

@MichaelEischer
Copy link
Copy Markdown
Member

What is the purpose of this change? What does it change?

The prune command rebuilds the repository index immediately after repacking unused packs. Rebuilding the index currently requires listing all packs in the repository. For an eventually consistent backend this can be a problem, as files may show up with some delay.

This PR lets the prune command itself keep track of all packs that should be contained in the rebuilt index. This side-steps the problems associated with listing the pack files.

Remaining design issues:

  • The selectedPacksRepo, which wraps a normal repository object but just returns the packs to be included in the new index, feels a bit like a hack. I've also made an attempt to explicitly pass in the list of packs to include in the index, however that resulted in special cases all the way between runPrune and index/index.New.
  • Tracking newly created packs involves a packHook which directly reaches into the packer_manager.savePacker. While this works it seems rather hacky, to directly reach into the repository object like that.
  • The datatype map[restic.ID]int64 used to map packs to their size, could probably use a proper type definition.

#2674 is a prerequisite to use this PR safely.

Was the change discussed in an issue or in the forum before?

No, but there have been some reports in the forum e.g. in https://forum.restic.net/t/fail-restic-stats-mode-raw-data/2601/16 .

Checklist

  • I have read the Contribution Guidelines
  • I have enabled maintainer edits for this PR
  • I have added tests for all changes in this PR
  • [ ] I have added documentation for the changes (in the manual)
  • There's a new file in changelog/unreleased/ that describes the changes for our users (template here)
  • 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

prune listed all pack files again after repacking the packs. This can be
a problem on eventual consistent backends where new files may show up
with some delay. This could cause the index rebuild to miss a few packs.

This change lets the prune command keep track of existing, removed and
newly created packs and specifically rebuild the index with these files.
This guarantees that the index will contain all relevant pack files.
@MichaelEischer
Copy link
Copy Markdown
Member Author

This PR is obsolete now that #2842 is merged.

@MichaelEischer MichaelEischer deleted the prune-eventual-list branch November 6, 2020 20:15
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.

1 participant