From 4d15725b6f3e2c38c011349cb5bd214fe1c34e1c Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Fri, 18 Jul 2025 14:18:49 +0300 Subject: [PATCH] sorter: fix sorter panic on SortedChunkIOState::WaitingForRead The following sequence of events is possible: - init_chunk_heap() called - chunk A status is WriteComplete, so chunk.read() gets called on chunk A - some other chunk B is in WaitingForWrite status after flush() - init_chunk_heap() returns IOResult::IO - init_chunk_heap() is called again - we panic because chunk A is in WaitingForRead status So - we just allow WaitingForRead status in init_chunk_heap() instead. This panic was caught thanks to Pedro's IO latency enhancement to the sim! --- core/vdbe/sorter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vdbe/sorter.rs b/core/vdbe/sorter.rs index 49d486810..d3e7c6b0d 100644 --- a/core/vdbe/sorter.rs +++ b/core/vdbe/sorter.rs @@ -149,7 +149,7 @@ impl Sorter { // Write complete, we can now read from the chunk. chunk.read()?; } - SortedChunkIOState::WaitingForWrite => { + SortedChunkIOState::WaitingForWrite | SortedChunkIOState::WaitingForRead => { all_read_complete = false; } SortedChunkIOState::ReadEOF | SortedChunkIOState::ReadComplete => {}