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

types migration #2478

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft

types migration #2478

wants to merge 32 commits into from

Conversation

imabdulbasit
Copy link
Contributor

@imabdulbasit imabdulbasit commented Jan 20, 2025

TODO:

  • test that after migration leaf1 type has been correctly converted to leaf2
  • better name for table tracking each migration instead of epoch_migration
  • call query service leaf migration function
  • indexes

Comment on lines +694 to +699
self.migrate_anchor_leaf().await?;
self.migrate_da_proposals().await?;
self.migrate_vid_shares().await?;
self.migrate_undecided_state().await?;
self.migrate_quorum_proposals().await?;
self.migrate_quorum_certificates().await
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we gate this by versions(and the other parts we start storing the new types) so we can merge this and not worry about deploying it

Comment on lines 702 to 719
async fn migrate_anchor_leaf(&self) -> anyhow::Result<()> {
Ok(())
}
async fn migrate_da_proposals(&self) -> anyhow::Result<()> {
Ok(())
}
async fn migrate_vid_shares(&self) -> anyhow::Result<()> {
Ok(())
}
async fn migrate_undecided_state(&self) -> anyhow::Result<()> {
Ok(())
}
async fn migrate_quorum_proposals(&self) -> anyhow::Result<()> {
Ok(())
}
async fn migrate_quorum_certificates(&self) -> anyhow::Result<()> {
Ok(())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think all of these should be fully implemented in the same PR

Copy link
Contributor Author

@imabdulbasit imabdulbasit Feb 6, 2025

Choose a reason for hiding this comment

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

this is default implementation. I have it implemented for SQL anf fs. I can remove this default implmentation to avoid confusion

@imabdulbasit imabdulbasit changed the title Ab/leaf2 migration types migration Feb 6, 2025
drop(tx);

if rows.is_empty() {
tracing::info!("no leaf1 rows found");
Copy link
Collaborator

@sveitser sveitser Feb 7, 2025

Choose a reason for hiding this comment

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

Is there a weird race condition here? Say we migrate exactly limit rows and it fails during the query that sets leaf_migration.completed=true. Then when we start up we will always try to perform the migration again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it should break here like we do in consensus migration

let (count,) = query_as::<(i64,)>("SELECT COUNT(*) from leaf2")
.fetch_one(tx.as_mut())
.await
.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of checking the number of rows it would be better to check that the data we migrated is as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in my todo list

let mut offset = 0;
let limit = 10000;

loop {
Copy link
Collaborator

@sveitser sveitser Feb 7, 2025

Choose a reason for hiding this comment

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

Lets' add some logs

  1. Inform about start of migration
  2. Inform about progress.
  3. Inform about completion.



CREATE TABLE undecided_state2 (
-- The ID is always set to 0. Setting it explicitly allows us to enforce with every insert or
Copy link
Collaborator

@sveitser sveitser Feb 7, 2025

Choose a reason for hiding this comment

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

Did you consider adding a constraint for only allowing the ID to be 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can add, these tables are just copy of older ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants