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

change(state): Prepare for in-place database format upgrades, but don't make any format changes yet #7031

Merged
merged 44 commits into from
Jul 13, 2023

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Jun 21, 2023

Motivation

We need a way to upgrade the on-disk database format, without re-syncing the whole chain.

Close #6955

Complex Code or Requirements

This is concurrent code, we need to be careful to shut down correctly, and regularly check for panics in the inner thread.

A lot of this code is modified from the block write task. We could refactor that task to use a generic ThreadHandle type in a future PR.

Solution

Implementation:

Logging:

Testing

zebrad tests:

  • Test that a newly created state is the current version, and re-opening it doesn't upgrade or downgrade the version
  • Test that a fake older state gets upgraded to the current version
  • Test that a fake newer state gets downgraded to the current version
  • Add extra test support functions and rename some existing functions

CI:

Related changes:

Review

This is a large PR, so I'm happy to do a video review, or split the test harness refactor and the CI changes into separate PRs.

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

Follow Up Work

See #6955:

  • documentation for format upgrades
  • optional format upgrade debugging log file
  • optional refactors

@teor2345 teor2345 added C-bug Category: This is a bug C-enhancement Category: This is an improvement P-Medium ⚡ I-panic Zebra panics with an internal error message I-hang A Zebra component stops responding to requests A-state Area: State / database changes A-concurrency Area: Async code, needs extra work to make it work properly. labels Jun 21, 2023
@teor2345 teor2345 requested a review from a team as a code owner June 21, 2023 02:47
@teor2345 teor2345 self-assigned this Jun 21, 2023
@teor2345 teor2345 requested review from oxarbitrage and removed request for a team June 21, 2023 02:47
@teor2345 teor2345 removed C-bug Category: This is a bug I-panic Zebra panics with an internal error message I-hang A Zebra component stops responding to requests labels Jun 21, 2023
@teor2345 teor2345 force-pushed the db-format-update-task branch from f4d3b0c to c82aa58 Compare June 21, 2023 02:52
@teor2345 teor2345 marked this pull request as draft June 21, 2023 02:52
@codecov

This comment was marked as outdated.

@teor2345 teor2345 force-pushed the db-format-update-task branch from c82aa58 to de24535 Compare June 25, 2023 23:24
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Jun 25, 2023
@teor2345 teor2345 added A-devops Area: Pipelines, CI/CD and Dockerfiles and removed C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG labels Jun 25, 2023
@teor2345 teor2345 changed the title change(state): Create an empty database format upgrade task change(state): Create an in-place database format upgrade task, but don't do any upgrades yet, needs Rust 1.70 Jun 25, 2023
@teor2345 teor2345 added the do-not-merge Tells Mergify not to merge this PR label Jun 30, 2023
@teor2345 teor2345 changed the title change(state): Create an in-place database format upgrade task, but don't do any upgrades yet, needs Rust 1.70 change(state): Create an in-place database format upgrade task, but don't do any upgrades yet Jul 2, 2023
@teor2345 teor2345 removed the do-not-merge Tells Mergify not to merge this PR label Jul 3, 2023
@teor2345 teor2345 force-pushed the db-format-update-task branch from de24535 to 8b90099 Compare July 5, 2023 23:22
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Jul 5, 2023
@teor2345

This comment was marked as resolved.

@teor2345 teor2345 force-pushed the db-format-update-task branch 2 times, most recently from 5fc7226 to 117f5b6 Compare July 7, 2023 02:18
@teor2345 teor2345 force-pushed the db-format-update-task branch from 7d4fd76 to 20e642e Compare July 9, 2023 20:28
@teor2345
Copy link
Contributor Author

I'm running a manual test of the workflow changes here:
ZcashFoundation/zebra/actions/runs/5502224802

This worked and created a disk with the correct version description and labels:

Screenshot 2023-07-10 at 13 01 34

arya2
arya2 previously approved these changes Jul 11, 2023
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Thank you for the well-organized tests and related cleanups.

zebra-state/src/constants.rs Outdated Show resolved Hide resolved
@teor2345
Copy link
Contributor Author

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Jul 12, 2023

update

✅ Branch has been successfully updated

@teor2345 teor2345 requested a review from arya2 July 13, 2023 19:02
mergify bot added a commit that referenced this pull request Jul 13, 2023
@mergify mergify bot merged commit be5cfad into main Jul 13, 2023
@mergify mergify bot deleted the db-format-update-task branch July 13, 2023 21:36
@teor2345 teor2345 mentioned this pull request Sep 1, 2023
40 tasks
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-devops Area: Pipelines, CI/CD and Dockerfiles A-state Area: State / database changes C-enhancement Category: This is an improvement C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an empty database format update task and format update tests
2 participants