-
Notifications
You must be signed in to change notification settings - Fork 476
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
ledger: report catchpoint writing only when it actually started #5413
ledger: report catchpoint writing only when it actually started #5413
Conversation
The original implementation was setting this flag in task producer, that created a gap between setting it and actual writing catchpoint in commitSyncer. Later, algorand#5214 introduced ability to skip tasks if the queue is full. This caused an issue with catchup service that was reading the flag with IsWritingCatchpointDataFile() and stopping the catchup. Because of that ledger was not receiving new blocks and was unable to schedule a new commit task but had the catchpoint writing flag set from the previous discarded task.
@@ -1625,14 +1625,6 @@ func (au *accountUpdates) prepareCommit(dcc *deferredCommitContext) error { | |||
// verify version correctness : all the entries in the au.versions[1:offset+1] should have the *same* version, and the committedUpTo should be enforcing that. | |||
if au.versions[1] != au.versions[offset] { | |||
au.accountsMu.RUnlock() | |||
|
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 code is the same as catchpointtracker's handleUnorderedCommitOrError
and called after commitRound / prepareCommit for all trackers in case of errors.
@@ -469,16 +469,13 @@ func (ct *catchpointTracker) produceCommittingTask(committedRound basics.Round, | |||
dcr.catchpointFirstStage = true | |||
|
|||
if ct.enableGeneratingCatchpointFiles { | |||
// store non-zero ( all ones ) into the catchpointWriting atomic variable to indicate that a catchpoint is being written ( or, queued to be written ) |
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 fix: moved to prepareCommit
Codecov Report
@@ Coverage Diff @@
## master #5413 +/- ##
==========================================
- Coverage 55.40% 55.39% -0.02%
==========================================
Files 452 452
Lines 63855 63854 -1
==========================================
- Hits 35379 35370 -9
- Misses 26044 26052 +8
Partials 2432 2432
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
} | ||
} | ||
if err != nil { |
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.
if another tracker overwrites the err with nil it won't be passed to handleUnorderedCommitOrError?
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.
maybe nest the error handling right inside the iteration, is this crazy?
for _, lt := range tr.trackers {
err := lt.prepareCommit(dcc)
if err != nil {
tr.log.Errorf(err.Error())
for _, lt := range tr.trackers {
lt.handleUnorderedCommitOrError(dcc)
}
tr.mu.RUnlock()
return err
}
}
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.
I had this before and did not really liked so moved out of the outer loop
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.
Current approach is pretty straightforward to follow now.
Updated per Chris review |
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 patch changes the manipulation pattern of a communication boolean shared between the catchup service and the catchpoint file generation service in order to prevent a slow-catchup-with-checkpoint-file-generation stall related to our new design of dropping commit tasks if a commit is already in progress (#5214). This boolean is now set and unset in the commit flow solely by the catchpoint tracker, and is no longer set in the commit scheduler or unset by other trackers.
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.
I think the logic managing this atomic variable is not the easiest to follow, but it works.
} | ||
} | ||
if err != nil { |
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.
Current approach is pretty straightforward to follow now.
Summary
The original implementation was setting this flag in task producer, that created a gap between setting it and actual writing catchpoint in commitSyncer.
Later, #5214 introduced ability to skip tasks if the queue is full. This caused an issue with catchup service that was reading the flag with IsWritingCatchpointDataFile() and stopping the catchup. Because of that ledger was not receiving new blocks and was unable to schedule a new commit task but had the catchpoint writing flag set from the previous discarded task.
Test Plan
Existing tests.
Manual catchup with catchpoints enabled up to round 170k.