mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 12:04:21 +01:00
Because `io_uring` may have many other I/O submission events queued (that are relevant to the operation) when we experience an error, marking our `Completion` objects as aborted is not sufficient, the kernel will still execute queued I/O, which can mutate WAL or DB state after we’ve declared failure and keep references (iovec arrays, buffers) alive and stall reuse. We need to stop those in-flight SQEs at the kernel and then drain the ring to a known-empty state before reusing any resources. The following methods were added to the `IO` trait: `cancel`: which takes a slice of `Completion` objects and has a default implementation that simply marks them as `aborted`. `drain`: which has a default noop implementation, but the `io_uring` backend implements this method to drain the ring. CC @sivukhin Reviewed-by: Pere Diaz Bou <pere-altea@homail.com> Closes #2787