-
Notifications
You must be signed in to change notification settings - Fork 343
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
refactor(general): move index cleanup out to refreshAttempt #3603
refactor(general): move index cleanup out to refreshAttempt #3603
Conversation
c406533
to
065cf05
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3603 +/- ##
==========================================
+ Coverage 75.86% 77.14% +1.27%
==========================================
Files 470 470
Lines 37301 28440 -8861
==========================================
- Hits 28299 21940 -6359
+ Misses 7071 4570 -2501
+ Partials 1931 1930 -1 ☔ View full report in Codecov by Sentry. |
065cf05
to
b7a65ce
Compare
e.maybeGenerateNextRangeCheckpointAsync(ctx, cs, p) | ||
e.maybeStartCleanupAsync(ctx, cs, p) | ||
e.maybeOptimizeRangeCheckpointsAsync(ctx, cs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is code movement only. These were at the end of refreshAttemptLocked
so putting them here has no functional changes, they just happened to be called right after refreshAttemptLocked
returns, instead of the last calls steps refreshAttemptLocked
.
e.maybeGenerateNextRangeCheckpointAsync(ctx, cs, p) | ||
e.maybeStartCleanupAsync(ctx, cs, p) | ||
e.maybeOptimizeRangeCheckpointsAsync(ctx, cs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the only caller, see comment above.
@@ -948,7 +960,7 @@ func (e *Manager) getIndexesFromEpochInternal(ctx context.Context, cs CurrentSna | |||
uncompactedBlobs = ue | |||
} | |||
|
|||
if epochSettled { | |||
if epochSettled && e.allowWritesOnLoad() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a functional change. It avoids advancing epoch when writes are disallowed.
Before: it attempted to advance the epoch (by writing a blob to the storage), even on read-only storage.
After: prevents advancing epochs when writes are disallowed on index loads, for example, when using read-only storage.
@@ -678,12 +704,6 @@ func (e *Manager) refreshAttemptLocked(ctx context.Context) error { | |||
len(ues[cs.WriteEpoch+1]), | |||
cs.ValidUntil.Format(time.RFC3339Nano)) | |||
|
|||
if !e.st.IsReadOnly() && shouldAdvance(cs.UncompactedEpochSets[cs.WriteEpoch], p.MinEpochDuration, p.EpochAdvanceOnCountThreshold, p.EpochAdvanceOnTotalSizeBytesThreshold) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to caller.
This was done "almost" at the end, but before returning an error in some cases.
It should not make a difference in practice though.
return e.maybeCompactAndCleanupLocked(ctx, p) | ||
} | ||
|
||
func (e *Manager) maybeCompactAndCleanupLocked(ctx context.Context, p *Parameters) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of this function is to group the epoch cleanup tasks that are performed during index loads, so it is simpler to manage.
The long term objective is to remove this code path from index loading altogether.
Introduces an `allowWritesOnLoadHelper` to check whether or not writes can be performed when loading the indexes. Currently this is only a function of whether the storage is in read-only mode. In the near future, an explicit flag will be added to control this behavior.
Functional change: prevents compacting single epochs when writes are disallowed, that is when using read-only storage. Currently, the epoch manager will attempt to perform single-epoch compactions for all eligible epochs, even on read-only storage. Ref: kopia#3225
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good to me
7b28438
to
84da027
Compare
@ashmrtn FYI |
Extracted from kopia#3651. Thanks to @plar and @redgoat650 for the suggestions. Ref: - kopia#3603 - kopia#3645 - kopia#3638 - kopia#3639
Refactor: move index compaction and cleanup out of refreshAttemptLocked Introduces an `allowWritesOnLoadHelper` to check whether or not writes can be performed when loading the indexes. Currently this is only a function of whether the storage is in read-only mode. In the near future, an explicit flag will be added to control this behavior. Fix epoch manager: avoid single-epoch compaction when writes are disallowed. Functional change: prevents compacting single epochs when writes are disallowed, that is when using read-only storage. Currently, the epoch manager will attempt to perform single-epoch compactions for all eligible epochs, even on read-only storage. Ref: - kopia#3224 - kopia#3225 - kopia#3638 - kopia#3639
Refactor: move index compaction and cleanup out of refreshAttemptLocked Introduces an `allowWritesOnLoadHelper` to check whether or not writes can be performed when loading the indexes. Currently this is only a function of whether the storage is in read-only mode. In the near future, an explicit flag will be added to control this behavior. Fix epoch manager: avoid single-epoch compaction when writes are disallowed. Functional change: prevents compacting single epochs when writes are disallowed, that is when using read-only storage. Currently, the epoch manager will attempt to perform single-epoch compactions for all eligible epochs, even on read-only storage. Ref: - kopia#3224 - kopia#3225 - kopia#3638 - kopia#3639
…3651) Perform index epoch compaction and cleanup during repository maintenance * refactor: rename maintenance task for deleting superseded indexes * maintenance task to cleanup epoch markers * maintenance task to advance write index epoch * maintenance task to compact epoch ranges * quick maintenance task to compact a single (index) epoch * full maintenance task to compact a single (index) epoch Ref: - #3638 - #3639 Followup to: - #3603 - #3645 Related helpers and changes: - #3721 - #3735 - #3709 - #3728 - #3727 - #3726
…opia#3651) Perform index epoch compaction and cleanup during repository maintenance * refactor: rename maintenance task for deleting superseded indexes * maintenance task to cleanup epoch markers * maintenance task to advance write index epoch * maintenance task to compact epoch ranges * quick maintenance task to compact a single (index) epoch * full maintenance task to compact a single (index) epoch Ref: - kopia#3638 - kopia#3639 Followup to: - kopia#3603 - kopia#3645 Related helpers and changes: - kopia#3721 - kopia#3735 - kopia#3709 - kopia#3728 - kopia#3727 - kopia#3726
Refactoring related to #3638 to simplify later PRs as much as possible.
These changes are mostly code movement except for a functional change noted below.
Changes
Move index compaction and cleanup out of
refreshAttemptLocked
, and perform it inrefreshLocked
afterrefreshAttempLock
succeeds. See inline comments.Refactor: Introduce an
allowWritesOnLoadHelper
to check whether or not writes can be performed when loading the indexes. Currently this is only a function of whether the storage is in read-only mode. In the near future, an explicit flag will be added to control this behavior.Functional change: Avoid single epoch compaction when writes are disallowed, that is when using read-only storage. Currently, the epoch manager will attempt to perform single epoch compactions, when it is time to do so, even on read-only storage.
Ref: