-
Notifications
You must be signed in to change notification settings - Fork 100
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
cleanup(state): Run possible minor database format version upgrades before deleting the disk version #8761
base: main
Are you sure you want to change the base?
Conversation
How important is this to merge soon? I would like @upbqdn to review it but he's not going to be back for a couple of weeks. |
It's not very important to merge soon. We can wait. |
DbFormatChange::Upgrade { | ||
older_disk_version, | ||
newer_running_version, | ||
} if !debug_skip_format_upgrades |
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 needs a correctness note about not running if read_only
so there's no corruption if multiple Zebra instances try to read and write the same files.
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.
Could we open an issue and do a refactor like this with any upcoming database upgrade instead? The upgrade will give us an opportunity to do thorough manual testing. I can open the issue.
I'd prefer to do thorough manual testing sooner to make outdated caches more usable, but we could split out everything except checking |
// It's fine to mark the database format as upgraded later if the database is empty | ||
if finalized_tip.is_some() { | ||
warn!("applying minor database format upgrades ahead of major format version bump, this may take a few minutes"); | ||
let (_cancel_tx, cancel_rx) = std::sync::mpsc::channel(); |
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 not using the sender will make Zebra irresponsive to shutdowns when the upgrade is running.
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.
Something like:
std::thread::spawn(move || {
while !is_shutting_down() {
if cancel_tx.is_closed() {
return;
}
std::thread::sleep(Duration::from_millis(1));
}
cancel_tx.send(CancelFormatChange);
});
might work here, but there's no is_closed()
method on this channel, so we'd need to replace it with a watch channel first.
&& RESTORABLE_DB_VERSIONS.contains(&newer_running_version.major) => | ||
{ | ||
warn!("upgrading database format to the next major version"); | ||
let db = new_db(Version::new(older_disk_version.major, u64::MAX, u64::MAX)); |
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.
Let's document why we're using u64::MAX
.
Co-authored-by: Marek <mail@marek.onl>
Motivation
Users could manually change the end of support time in code, use a version of Zebra published without an end-of-support halt, or have an outdated state cache produced by a version of Zebra that has reached its end-of-support but hasn’t been run in a long time (perhaps on Testnet).
We may also publish minor version upgrades in the future shortly before a major version upgrade that can be restored from a previous database format.
Solution
Related changes:
Tests
Needs manual testing:
PR Author's Checklist
PR Reviewer's Checklist