Cancellation in async rust #
At Rust India Conference 2026.
Covers the following topics:
- Introduction to the internals of async Rust and how cancellation works: a mental model of Rust futures, how
tokio::select!works - Two “types” of cancellations: dropping and pausing. And why pausing is almost always a bug.
- Problems with cancellation: invalid state being leaked, deadlocks, etc.
- How DataFusion uses tokio task budgets to cancel CPU-heavy futures.
- Builds to up the idea of task budgets from first principles.
- Production bug we had faced at e6data, related to cancellation: the app was deadlocked even when the mutexes were unlocked.
- Includes a brief look at the internals of Tokio’s mutex.
Recording #
Slides #
Reach out to us #
- Presenter: me (GitHub, LinkedIn)
- Special thanks to the team: Amit, Aayush, Nimalan, Faiz and Fenil for reviewing the content.
Resources #
- Never snooze a future - Jack O’Connor
- Cancelling async rust by Rain or Oxide RFD 400
- Using Rust async for Query Execution and Cancelling Long-Running Queries - DataFusion Team
- Tokio blog post introducing task budgets and
tokio::task::coopdocs. - Andrew Lamb’s talk on using tokio for CPU heavy tasks for DataFusion
- Deadlocking a tokio mutex without holding a lock
- Oxide RFD 609 - Futurelock