Move finalized state database and filesystem operations to blocking threads to avoid hangs #2188
Closed
Labels
A-rust
Area: Updates to Rust code
C-bug
Category: This is a bug
I-hang
A Zebra component stops responding to requests
I-slow
Problems with performance or responsiveness
I-usability
Zebra is hard to understand or use
Previous Work
We tried to fix this in PR #4199.
It worked, but it didn't help performance much, and the extra threading caused some fragile tests to intermittently fail.
Scheduling
We should only to this ticket if we fix the other hang bugs, and Zebra still hangs frequently.
Is your feature request related to a problem? Please describe.
Zebra runs finalized state database and filesystem operations on async threads, which can block:
Describe the solution you'd like
Instead, Zebra should:
spawn_blocking
function to run these tasks, andasync
functions (or access the executor directly)https://docs.rs/tokio/1.6.0/tokio/task/fn.spawn_blocking.html
Describe alternatives you've considered
We can use tokio's
block_in_place
function, and move test code into atokio::test
. This function only blocks concurrent code in the same task. This makes it suitable for initialization or finalization tasks, because we're not doing much concurrent work at that time.We could also use
block_in_place
as we transition code.Additional context
Blocking functions might be the source of hangs or slowdowns in the inbound service, or state service, or unrelated tasks.
The text was updated successfully, but these errors were encountered: