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

[Storage Refactor] Refactor ConsumerProgress #6872

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

zhangchiqing
Copy link
Member

This PR refactors consumer progress to use badger batch updates instead of transactions.

Also created a ConsumerProgressInitializer to separate the initialization process.

@zhangchiqing zhangchiqing changed the base branch from master to leo/db-ops-dbstore January 10, 2025 22:39
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 17.97235% with 178 lines in your changes missing coverage. Please review.

Project coverage is 41.15%. Comparing base (b740fc0) to head (5deb562).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
storage/mock/batch.go 0.00% 46 Missing ⚠️
storage/mock/db.go 0.00% 44 Missing ⚠️
storage/mock/consumer_progress_initializer.go 0.00% 28 Missing ⚠️
cmd/access/node_builder/access_node_builder.go 0.00% 22 Missing ⚠️
cmd/observer/node_builder/observer_builder.go 0.00% 12 Missing ⚠️
storage/store/consumer_progress.go 78.57% 6 Missing and 3 partials ⚠️
cmd/verification_builder.go 0.00% 7 Missing ⚠️
storage/operation/consume_progress.go 0.00% 4 Missing ⚠️
module/jobqueue/consumer.go 40.00% 2 Missing and 1 partial ⚠️
engine/testutil/nodes.go 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6872      +/-   ##
==========================================
+ Coverage   41.11%   41.15%   +0.03%     
==========================================
  Files        2116     2118       +2     
  Lines      185749   185815      +66     
==========================================
+ Hits        76378    76474      +96     
+ Misses     102954   102920      -34     
- Partials     6417     6421       +4     
Flag Coverage Δ
unittests 41.15% <17.97%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhangchiqing zhangchiqing changed the base branch from leo/db-ops-dbstore to master January 11, 2025 01:51
@zhangchiqing zhangchiqing marked this pull request as ready for review January 15, 2025 16:26
@zhangchiqing zhangchiqing requested a review from a team as a code owner January 15, 2025 16:26
Copy link
Member

@AlexHentschel AlexHentschel Jan 15, 2025

Choose a reason for hiding this comment

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

May I suggest a minor documentation upgrade of line 47 to further improve accuracy of documentation:

// - codes.ErrIncorrectValue - if stored value is larger than processed.

Let current denote the counter's current value and processed is the new value.

  • According to the documentation, we error codes.ErrIncorrectValue if current > processed. This implies that a Set(processed) operation where processed = current should succeed.
  • The error describes, in which cases we reject a new element. Of course, we reject the new element (processed), when it is smaller - this is correctly reflected in the documentation. But we also reject elements that have the same value, which is missing from the documentation.
  • Note that this is the difference between monotonous increasing and strict monotonous increasing. Monotonous allows values to repeat (they just can't get smaller). E.g. 8, 12, 13, 13, 13, 100 is a monotonously increasing sequence. But it is not strictly monotonous increasing, because some elements have the same value (13) as the prior element, which is not allowed for strict monotonous increasing.

I would suggest to replace line 47 by

//   - codes.ErrIncorrectValue - if stored value is ≥ processed (requirement of strict monotonous increase is violated).

return err
}

lastFullBlockHeight, err = counters.NewPersistentStrictMonotonicCounter(progress)
Copy link
Member Author

Choose a reason for hiding this comment

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

NewPersistentStrictMonotonicCounter now only takes a consumer progress that has been initialized. The initialization steps is moved out of the PersistentStrictMonotonicCounter, so that the initialization logic can be reused by other modules, and forces the caller to initialize the progress before being used by the counter.

It also simplifies the counter, as it doesn't need to worry about whether the progress has been initialized or not, since it must have been initialized.

@@ -0,0 +1,87 @@
package store
Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually renamed from storage/badger/consumer_progress.go, github wasn't able to recognize this move, but think it's a new file.

@@ -0,0 +1,58 @@
package store
Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually renamed from storage/badger/consumer_progress_test.go, github wasn't able to recognize this move, but think it's a new file.

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.

3 participants