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

indexer: refactor migration logic to use an async connection #19259

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

bmwill
Copy link
Contributor

@bmwill bmwill commented Sep 6, 2024

Description

Describe the changes or additions included in this PR.

Test plan

How did you test the new or updated feature?


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Sep 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 6, 2024 9:24pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 6, 2024 9:24pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 6, 2024 9:24pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 6, 2024 9:24pm

info!("Dropped all functions.");

conn.setup()?;
info!("Created __diesel_schema_migrations table.");
// conn.setup()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional? the setup call creates the diesel record table. I guess you could revert it back to explicit sql if it's hard to turn it into async

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 don't believe this explicit call to setup is necessary, without it all the tests still pass properly. Its likely handled as a part of the run_pending migrations flow. I'll remove the commented out line though

reset_database(pool.dedicated_connection().await.unwrap())
.await
.unwrap();
check_db_migration_consistency(&mut pool.get().await.unwrap())
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason one uses dedicated while the other use non-dedicated?

Copy link
Contributor Author

@bmwill bmwill Sep 6, 2024

Choose a reason for hiding this comment

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

yes, reset_database requires an owned connection that is passed by value while the consistency check just needs one by &mut. This is due to needing to send the owned connection to a blocking thread to run the migrations.

@bmwill bmwill enabled auto-merge (rebase) September 6, 2024 21:29
@bmwill bmwill merged commit f811a09 into MystenLabs:main Sep 6, 2024
44 of 45 checks passed
@bmwill bmwill deleted the indexer-async-migrations branch September 6, 2024 21:30
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