feat: Add async_backtrace instrumentation to store, fetch, and push#628
Merged
feat: Add async_backtrace instrumentation to store, fetch, and push#628
Conversation
Wire up the async-backtrace crate so we can introspect the live async call graph when the broker hangs or misbehaves. All async fns in the postgres store and the fetch/push pipelines are decorated with #[framed], the spawned worker/fetch loops are wrapped with frame!() (they're separate task roots that #[framed] on the parent does not reach), and the upkeep loop dumps taskdump_tree(false) at debug! every 30 seconds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
george-sentry
approved these changes
May 8, 2026
Add `log_async_backtrace: bool` to Config (default false) and gate the periodic taskdump_tree emission in the upkeep loop on it. The dump can be expensive and noisy, so operators opt in when they need it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wire up the async-backtrace crate so we can introspect the live async call graph when the broker hangs or behaves unexpectedly. The upkeep loop logs the current
taskdump_treesnapshot atdebug!every 30 seconds, gated on a new config flag.Where
#[framed]is appliedAll async fns in
src/store/adapters/postgres.rs(module-level pool helpers,PostgresActivationStoreconstructors, and everyInflightActivationStoretrait method), plus the async fns insrc/push/mod.rs(WorkerClient::send,PushPool::start,PushPool::submit,push_task) andsrc/fetch/mod.rs(TaskPusher::submit_task,FetchPool::start).Spawned workers wrapped with
frame!()PushPool::startandFetchPool::startspawn their actual loops viacrate::tokio::spawn_pool. Each spawned future is a separate task root, so#[framed]on the parent does not propagate. The innerasync move { ... }bodies are now wrapped withasync_backtrace::frame!(...)so fetch and push workers show up as roots in the dump tree, with in-flight postgres calls hanging off them.New config flag:
log_async_backtraceConfig::log_async_backtrace: bool(defaultfalse) controls the periodic dump. When enabled,upkeep()emitsdebug!(backtrace = %tree, "async backtrace dump")withasync_backtrace::taskdump_tree(false)if 30s has elapsed since the last dump.falsefortaskdump_treemeans non-blocking — frames currently being polled are skipped rather than waited on. Off by default since the tree can be large and noisy; operators opt in when diagnosing a hang.