Skip to content

ScanScheduler leaks when caller drops request future which leads to request deadlocks. #7619

Description

@valkum

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions