Summary
Both standard and lite schedulers are not cancellation safe. When a request future is dropped, the backpressure reservation is only refunded when the future is polled to completion.
Root cause
Standard scheduler: IoQueueState::next_task will place a reservation self.priorities_in_flight.push(task.priority);. This reservation is returned in IoQueue::on_bytes_consumed which is only called from the returned future in submit_request_standard.
If this future is dropped before it is polled to completion, the closure never runs. The spawned I/O task will run to completion but will encounter a gone oneshot::Receiver.
Lite scheduler: Here the IoTask owns BackpressureReservation. The reservation is only returned when the task reaches the Finished state. For this, the TaskHandle needs to be polled to completion.
SimpleBackpressureThrottle::release never fires if the request future is dropped.
Expected behavior
Subsequent requests should not be starved.
Actual Behavior
The reservation leaks and follow-up requests deadlock.
Fix
Add Drop impls that refund reservations. I have a PR ready and will submit soon.
Summary
Both standard and lite schedulers are not cancellation safe. When a request future is dropped, the backpressure reservation is only refunded when the future is polled to completion.
Root cause
Standard scheduler:
IoQueueState::next_taskwill place a reservationself.priorities_in_flight.push(task.priority);. This reservation is returned inIoQueue::on_bytes_consumedwhich is only called from the returned future insubmit_request_standard.If this future is dropped before it is polled to completion, the closure never runs. The spawned I/O task will run to completion but will encounter a gone oneshot::Receiver.
Lite scheduler: Here the
IoTaskownsBackpressureReservation. The reservation is only returned when the task reaches theFinishedstate. For this, theTaskHandleneeds to be polled to completion.SimpleBackpressureThrottle::releasenever fires if the request future is dropped.Expected behavior
Subsequent requests should not be starved.
Actual Behavior
The reservation leaks and follow-up requests deadlock.
Fix
Add Drop impls that refund reservations. I have a PR ready and will submit soon.