From 9690eb41c2017b28940386535024824710b496e8 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Sat, 12 Jul 2025 18:24:04 -0300 Subject: [PATCH] `make_from_btree` should wait for IO to complete if we do not want to use a state machine --- core/schema.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/core/schema.rs b/core/schema.rs index 89fafec67..d1b7d511a 100644 --- a/core/schema.rs +++ b/core/schema.rs @@ -157,19 +157,21 @@ impl Schema { let mut automatic_indices: HashMap> = HashMap::with_capacity(10); - match pager.begin_read_tx()? { - IOResult::Done(v) => { - if matches!(v, LimboResult::Busy) { - return Err(LimboError::Busy); + loop { + match pager.begin_read_tx()? { + IOResult::Done(v) => { + if matches!(v, LimboResult::Busy) { + return Err(LimboError::Busy); + } + break; } + IOResult::IO => pager.io.run_once()?, } - IOResult::IO => pager.io.run_once()?, } - match cursor.rewind()? { - IOResult::Done(v) => v, - IOResult::IO => pager.io.run_once()?, - }; + while let IOResult::IO = cursor.rewind()? { + pager.io.run_once()? + } loop { let Some(row) = (loop { @@ -285,9 +287,9 @@ impl Schema { drop(record_cursor); drop(row); - if matches!(cursor.next()?, IOResult::IO) { + while let IOResult::IO = cursor.next()? { pager.io.run_once()?; - }; + } } pager.end_read_tx()?;