Skip to content

Fix block_on usage in connect #2033

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

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

Conversation

avinassh
Copy link
Member

fixes #2032

@avinassh avinassh requested a review from Copilot April 16, 2025 13:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses issue #2032 by fixing the usage of tokio’s block_on functionality in the database bootstrap process. Key changes include:

  • Replacing the previous tokio::task::block_in_place call with a conditional branch based on the presence of a synchronization context.
  • Introducing a new branch to handle runtime availability via tokio::runtime::Handle::try_current(), with distinct handling for when a current runtime exists and when it does not.
Comments suppressed due to low confidence (1)

libsql/src/database.rs:695

  • Consider handling potential errors when building the Tokio runtime instead of using unwrap(), to avoid an unexpected panic in production environments.
.build().unwrap();

@avinassh avinassh marked this pull request as ready for review April 17, 2025 11:39
@avinassh avinassh requested review from penberg and levydsa April 17, 2025 11:39
@avinassh avinassh force-pushed the bootstrap-db-thread branch from 19fa75a to 84c2239 Compare April 17, 2025 12:08
@avinassh avinassh marked this pull request as draft April 17, 2025 13:44
@avinassh
Copy link
Member Author

Okay, this might not be the proper way to handle this.

https://greptime.com/blogs/2023-03-09-bridging-async-and-sync-rust

https://stackoverflow.com/a/66280983

@penberg penberg changed the title bugfix: fix currect use of block_on Fix block_on usage in connect Apr 17, 2025
@avinassh avinassh force-pushed the bootstrap-db-thread branch from 84c2239 to 652f432 Compare April 23, 2025 09:55
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.

db.connect panics when used in a single threaded environment
2 participants