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

High Availability - sync over DB, multiple process instances support #718

Closed
wants to merge 12 commits into from

Conversation

piohei
Copy link
Contributor

@piohei piohei commented Apr 29, 2024

Motivation

It is required to run signup-sequencer with HA.

Solution

Sync workers over DB.

PR Checklist

  • Added Tests
  • Added Documentation

@@ -0,0 +1,25 @@
-- Create ENUM for prover type
CREATE TYPE batch_type_enum AS ENUM ('Insertion', 'Deletion');
Copy link
Contributor

Choose a reason for hiding this comment

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

Postgres enums are tricky as you can't add a variant to them later down the line.

I would suggest changing it to a number or string.

Another option is a table with allowed values but that's a bit overkill imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have seen we were using it for "prover_type" (file 008_prover_type.sql). What we prefer? Do it like for prover or just use String field and parse on rust side?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use string here I think. There's a very real chance we'll add an Update batch type in the future and that's a breaking change if we're using enums.

async fn get_next_batch(self, prev_root: &Hash) -> Result<Option<BatchEntry>, Error> {
let res = sqlx::query_as::<_, BatchEntry>(
r#"
SELECT * FROM batches WHERE prev_root = $1
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider explicitly listing all fetched columns here.

I think the * might break if we're deploying a new version of a sequencer with a DB schema update as the older version will try to fetch columns that it doesn't know how to parse.

By listing all columns explicitly we'll be able to add columns without breaking previous sequencer versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also applies to other usages of *

@piohei piohei closed this Aug 13, 2024
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.

2 participants