From c8d2a1a4801d86499762ec7dd3218b154fff2443 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Wed, 6 Aug 2025 13:39:20 +0300 Subject: [PATCH] btree: add a few more assertions about balance state --- core/storage/btree.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 40c3b8fcc..adc0d5334 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -2256,6 +2256,7 @@ impl BTreeCursor { let overflows = !page.get().get_contents().overflow_cells.is_empty(); if overflows { *write_state = WriteState::Balancing; + assert!(self.balance_state.sub_state == BalanceSubState::Start, "There should be no balancing operation in progress when insert state is {:?}, got: {:?}", self.state, self.balance_state.sub_state); // If we balance, we must save the cursor position and seek to it later. // FIXME: we shouldn't have both DeleteState::SeekAfterBalancing and // save_context()/restore/context(), they are practically the same thing. @@ -2311,6 +2312,7 @@ impl BTreeCursor { }; if overflows || underflows { *write_state = WriteState::Balancing; + assert!(self.balance_state.sub_state == BalanceSubState::Start, "There should be no balancing operation in progress when overwrite state is {:?}, got: {:?}", self.state, self.balance_state.sub_state); // If we balance, we must save the cursor position and seek to it later. // FIXME: we shouldn't have both DeleteState::SeekAfterBalancing and // save_context()/restore/context(), they are practically the same thing.