-
Notifications
You must be signed in to change notification settings - Fork 107
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
change(state): Check database format is valid every 5 minutes, to catch format errors in new block code #7602
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
teor2345
added
P-Medium ⚡
C-testing
Category: These are tests
A-state
Area: State / database changes
A-concurrency
Area: Async code, needs extra work to make it work properly.
labels
Sep 21, 2023
Does this run on CI only or on any running zebra instance? |
oxarbitrage
requested review from
upbqdn
and removed request for
oxarbitrage
September 21, 2023 12:44
This runs on all Zebra instances, because if the database format is wrong, then we can break a consensus rule, or send incorrect data to wallets. (We already run these checks at startup, but that's not enough to detect all format bugs.) |
teor2345
force-pushed
the
flsync-valid
branch
from
September 21, 2023 23:01
bbe7c02
to
42d87cd
Compare
upbqdn
approved these changes
Sep 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-concurrency
Area: Async code, needs extra work to make it work properly.
A-state
Area: State / database changes
C-testing
Category: These are tests
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
We want to catch format errors in new block code. But currently that code is only tested when Zebra adds new blocks, then shuts down, then opens the same state. So PRs can merge with bugs in that code.
Instead, we check the format is valid every 5 minutes while Zebra is running.
This is the periodic part of #7570.
Complex Code or Requirements
We can't run this code too often, or it will impact performance. But we want to make sure it gets run during most tests, so we catch bugs early.
Solution
Continue running the format change thread after the initial change finishes, then periodically run a format check:
Related changes:
Example Logs
On startup, it takes 2 seconds to open the database, and 7 seconds to check the format is valid:
So the format check is running approximately 2% of the time. Since it runs in parallel with the rest of the code, and it will be faster when the data is in the database memory cache, this is acceptable performace.
Review
This is on the critical path for finishing off the subtree work. It's not strictly required for the 1.3.0 release, but it would help to find any other data bugs.
Reviewer Checklist