-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[testnet] introduce new database schema and migration tooling. #4865
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
[testnet] introduce new database schema and migration tooling. #4865
Conversation
afck
left a comment
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.
Looks great! The only remaining potential blocker for me is the mem::size_of issue.
| // This implies that data on those root keys do not need to be moved. | ||
| // For other tag variants, that are on the shared partition, we need to move | ||
| // the data into their own partitions. | ||
| const MOVABLE_KEYS_0_1: &[u8] = &[1, 2, 3, 4, 5, 7]; |
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.
It would be good to point out that 0 and 6 correspond to ChainState and BlockExporter, respectively (if I understand what this is correctly... it's not obvious even with the comment, I'm afraid 😬 )
| for root_key in root_keys { | ||
| if root_key.len() == 1 + BLOB_ID_LENGTH && root_key[0] == BLOB_ID_TAG { | ||
| let root_key_red = &root_key[1..=BLOB_ID_LENGTH]; | ||
| if !root_key.is_empty() && root_key[0] == BLOB_ID_TAG { |
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.
Good catch! 👍
Motivation
The existing database schema is flawed because it consolidates all blobs, blob states, confirmed blocks, and events under a single root key (the shared one
&[]).We change this here.
Proposal
The new schema is chosen with the following goal in mind:
ChainStateandBlockExplorerremain in the same place.RootKeytype is only used for getting theroot_keyin contrast toBaseKey, which serves two purposes: root_key for some variants, key for some others.Of utmost importance is to have a viable migration path. This is done according to the following points:
linera-migrationis introduced.For testing, a test
test_storage_migrationis introduced. It does the following:RocksDB,ScyllaDB, andmemory. This is not done forDynamoDBbecause of a problem with this database that will soon be addressed.Of relevance is the annoying fact that root keys of the form
&[]are not handled correctly forRocksDBandlinera-storage-service. This turns out not to be a problem:find_keys_by_prefix(&[])on the shared partition would get you keys from other root keys. However, that use case does not occur.find_keys_by_prefix(&[x])forxa byte that is NOT the first byte of other root keys. So it works.Test Plan
The CI.
Release Plan
TestNet Conway is the target.
Links
None.