Skip to main content

Module cancel

Module cancel 

Source
Expand description

Cooperative query cancellation.

Queries already carry an optional deadline that the executor checks at operator boundaries and inside hot loops. Cancellation rides on that mechanism instead of threading a second token through every operator: a cancellable query is given a unique deadline instant, and cancelling it records that instant in a small process-wide set. The deadline check consults the set, so a cancelled query stops at its next check point on whichever thread is running it (including parallel workers), and then unwinds through the normal timeout path: the error propagates, WAL transactions abort, and locks are released.

The set is only consulted while at least one cancellation is pending, so queries that never use cancellation pay one relaxed atomic load.

Structs§

CancellableDeadline
A deadline that can also be cancelled before it expires.

Functions§

deadline_reached
True once deadline has passed or its query was cancelled.