Skip to content

Systematic: spawn_blocking(...).await.unwrap() panics on JoinError::Cancelled during shutdown (beyond #949) #1031

Description

@atharaldsen

#949 (fixed in #1030) addressed a graceful-shutdown panic in ConsensusSessionOwned::spawn_blocking (components/consensusmanager/src/session.rs): on runtime teardown a queued blocking task is cancelled, the join returns Err(JoinError::Cancelled), and .await.unwrap() panics a worker thread.

The same spawn_blocking(...).await.unwrap() pattern appears elsewhere with the same shutdown-cancellation panic surface:

  • mining/src/manager.rsMiningManagerProxy methods (get_realtime_feerate_estimations, get_transaction, has_transaction, transaction_count, get_all_transactions, get_transactions_by_addresses, has_accepted_transaction, unaccepted_transactions, unknown_transactions). Structurally identical to the session proxy and RPC-reachable.
  • indexes/utxoindex/src/core/api/mod.rsUtxoIndexProxy methods (get_circulating_supply, get_utxos_by_script_public_keys, get_balance_by_script_public_keys, update). Same proxy pattern, RPC-reachable.
  • protocol/flows/src/ibd/flow.rs:163, 602 — staging commit / consensus reset during IBD.
  • components/connectionmanager/src/lib.rs:257, 281 — dns_seed spawn_blocking / try_join_all.

(Sim/test code such as simpa and testing/integration excluded as lower priority. The async-runtime shutdown orchestrator in core/src/task/runtime.rs and the timeout-wrapped join in utils/src/sync/rwlock.rs are excluded as different semantics.)

Suggested approach

Apply the same handling as #949: on is_cancelled() (runtime shutdown, no result to return) park until teardown; on a genuine closure panic propagate via resume_unwind. This could be factored into a small shared helper (e.g. in kaspa-core/kaspa-utils) so the proxies/flows reuse it instead of open-coding .await.unwrap().

Filed separately from #949 to keep that fix scoped to the observed crash site.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions