Skip to content

Fix block_on usage in connect#2033

Closed
avinassh wants to merge 2 commits intotursodatabase:mainfrom
avinassh:bootstrap-db-thread
Closed

Fix block_on usage in connect#2033
avinassh wants to merge 2 commits intotursodatabase:mainfrom
avinassh:bootstrap-db-thread

Conversation

@avinassh
Copy link
Copy Markdown
Member

fixes #2032

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

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 levydsa and penberg 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
Copy Markdown
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
@penberg
Copy link
Copy Markdown
Collaborator

penberg commented Sep 16, 2025

Closing as obsolete

@penberg penberg closed this Sep 16, 2025
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

3 participants