Skip to content

Conversation

@lutter
Copy link
Collaborator

@lutter lutter commented Oct 11, 2025

We have a lot of places where we do blocking database work from a non-blocking tokio task. This PR addresses this longstanding issue by using async database connections and diesel_async. With that, we don't need to rely on error-prone approaches that require spawning blocking tasks whenever we do database work.

Most of this PR is concerned with sprinkling async/await throughout the code base. There are a lot of commits, but most of them are boring, and I tried to structure it so that many of them just add async/await in a few places to make them easy to review individually.

Since switching to async connections also requires changing the connection pool, towards the end of the PR there are changes to recreate the instrumentation we had with r2d2 with deadpool.

There are still places in the codebase where spawn_blocking is used, but those can be removed in separate PR's as this one is already crazy long. My apologies to the reviewer(s)

I made sure that cargo check passed after each commit; in addition, I ran CI after every few (say 5-10) commits and made sure that passed, too, up to the commit marked SQUASH FROM HERE as it was not possible to pass CI from that point on until CI PASSES AGAIN as the AsyncConnectionWrapper uses block_on for db interactions, and too many of them happen on the main tokio threads. For those, tokio panics as you are not allowed to use block_on on those threads.

Fixes #905

@lutter lutter force-pushed the lutter/async-store branch 6 times, most recently from 2be39ef to 63352af Compare October 13, 2025 19:13
@lutter lutter force-pushed the lutter/async-store branch 5 times, most recently from 5877de5 to 212b69c Compare October 22, 2025 15:52
@lutter lutter force-pushed the lutter/async-store branch from 212b69c to 9f0ce51 Compare October 22, 2025 16:48
@lutter lutter force-pushed the lutter/async-store branch from 321656a to 9356607 Compare October 23, 2025 15:21
@lutter lutter marked this pull request as ready for review October 23, 2025 15:31
@lutter lutter force-pushed the lutter/async-store branch from 9356607 to 6e768dc Compare October 23, 2025 15:34
@lutter lutter changed the title WIP: Make all store/db interactions async Make all store/db interactions async Oct 23, 2025
@isum isum self-requested a review October 29, 2025 06:42
We have runner tests failing frequently because the store seems to get
dropped while it still has pending writes. This change attempts to prevent
that by flushing the store when we encounter a fatal error.
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.

Move slow db interactions to tokio blocking pool

2 participants