Make storage version upgrades a ceremony (warn, opt-out flag, strict version mapping) - #788
Closed
jonasvanderhaegen wants to merge 1 commit into
Closed
Conversation
- warn on stderr when a checkpoint upgrades the on-disk storage version - new SystemConfig/CALL option allow_storage_version_upgrade (default true): when false, such a checkpoint throws instead of upgrading; the check runs before WAL rotation so a refusal mutates nothing - getStorageVersion() now throws on a version string with no mapping instead of silently using the max known storage version - readDatabaseHeader only treats a magic-bytes mismatch as 'no header'; a version mismatch now propagates (shadow-file recovery previously reported it as corruption) - tests for the old-binary refusal path (resolves the TODO in database_header.cpp) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5 tasks
Contributor
Author
|
Closing: this work now lives in our fork (skylence-be/ladybug) rather than as an upstream contribution. Thanks. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Makes storage-format upgrades a visible ceremony instead of a silent side effect:
SystemConfigfield /CALLoptionallow_storage_version_upgrade(defaulttrue, so behavior is unchanged unless you set it). Whenfalse, such a checkpoint throws aRuntimeExceptionnaming both versions instead of upgrading; the file stays readable by the release that wrote it. The check runs beforecheckpointStorage(), so on refusal the data file is untouched.Database::~Databasealready catches close-time checkpoint exceptions, so a refusal on close simply skips the upgrade.StorageVersionInfo::getStorageVersion()previously fell back to the max storage version in the map whenLBUG_CMAKE_VERSIONhad no entry. That fallback only fires when a release forgot to update the map — and silently guessing the newest format in that state converts a release-process mistake into invisible format skew. It now throws with an actionable message. The current version string (0.20.0) is mapped, and 4-component nightly strings are truncated to 3 components before lookup, so no supported build path hits the throw.DatabaseHeader::readDatabaseHeadercaught everyRuntimeExceptionand returned "no header". A version-mismatched header now propagates; only a magic-bytes mismatch (the optimistic pre-checkpoint write case) still reads as "no header". Visible effect: shadow-file recovery under a version-mismatched header now reports the real version error instead of "The database is corrupted, please recreate it."TODO(Guodong)indatabase_header.cpp: unit tests for the version mapping (including the throw), api tests that rewrite the header's storage version and assert the open-time refusal message, thereadDatabaseHeaderpropagation/no-magic behaviors, and the checkpoint opt-out round-trip; plus an e2e case exercisingallow_storage_version_upgradeend to end.Why
A storage-version upgrade is a one-way door: after it, every older binary refuses the file. Today the door closes silently on the first checkpoint. This PR keeps the default behavior but makes the door visible (warning), lockable (flag), and honest about failure modes (strict version mapping, propagated version mismatch).
Tests
api_test --gtest_filter='StorageVersionMappingTest.*:StorageVersionCeremonyTest.*'(7 new tests)storage_version.test: newStorageVersionUpgradeOptOutcasestorage_version.StorageVersionFunctionAndUpgradeunchanged and passing🤖 Generated with Claude Code