-
Notifications
You must be signed in to change notification settings - Fork 43
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
Ledger db migrations #1358
Ledger db migrations #1358
Conversation
f91a0f0
to
a68a4c9
Compare
for (index, value) in values.into_iter().enumerate() { | ||
ledger_db.put_value(index as u64, (index as u64, value))?; | ||
} |
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.
we could also create the new table here right?
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.
Yes, TestTableNew
is a new table and the call to put_value
here is adding entries into this new table.
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.
but isn't that table already in the schema when you start the process? I'm talking about creating a new table that we haven't defined in LEDGER_TABLES
previously, but we do now, with the migration
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.
So tables are not "created" when you start the process. They are created as soon as you write to them.
When we create the inner: DB
part of the LedgerDB
, we pass the schema of those tables but it won't actually create them until they're written to.
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.
The idea behind the TestTableNew
is to demonstrate how we can define the new table's schema and we add it to the code and we get the code to use it. However, it doesn't mean that it has data to be used. That's what migrations are for.
ac09758
to
b947778
Compare
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.
LGTM
Description
This PR implements a migrator which atomically executes ledger DB migrations. The process runs as follows:
This happens of course, in case where no ledger DB instance holds the lock on the directory. Otherwise, the process will fail.
This also implements the possibility to execute different migrations for each of sequencer, full node and prover.
TODO
Linked Issues