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

ledger: report catchpoint writing only when it actually started #5413

Merged

Conversation

algorandskiy
Copy link
Contributor

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.

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()

Copy link
Contributor Author

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 )
Copy link
Contributor Author

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
Copy link

codecov bot commented May 23, 2023

Codecov Report

Merging #5413 (b7f1cd4) into master (1abbd50) will decrease coverage by 0.02%.
The diff coverage is 64.00%.

@@            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              
Impacted Files Coverage Δ
ledger/ledger.go 71.03% <0.00%> (ø)
ledger/tracker.go 73.51% <33.33%> (-1.49%) ⬇️
ledger/acctonline.go 79.38% <100.00%> (+0.30%) ⬆️
ledger/acctupdates.go 71.19% <100.00%> (-0.19%) ⬇️
ledger/bulletin.go 95.65% <100.00%> (ø)
ledger/catchpointtracker.go 59.78% <100.00%> (+0.11%) ⬆️
ledger/metrics.go 100.00% <100.00%> (ø)
ledger/notifier.go 88.23% <100.00%> (ø)
ledger/spverificationtracker.go 96.37% <100.00%> (ø)
ledger/txtail.go 78.21% <100.00%> (ø)

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

ledger/tracker.go Show resolved Hide resolved
}
}
if err != nil {
Copy link
Contributor

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?

Copy link
Contributor

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
		}
	}

Copy link
Contributor Author

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

Copy link
Contributor

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.

@algorandskiy algorandskiy requested a review from cce May 24, 2023 15:24
@algorandskiy
Copy link
Contributor Author

Updated per Chris review

Copy link
Contributor

@bbroder-algo bbroder-algo left a 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.

Copy link
Contributor

@gmalouf gmalouf left a 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 {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants