diff --git a/core/storage/pager.rs b/core/storage/pager.rs index 09cd09b90..6d8f5e63c 100644 --- a/core/storage/pager.rs +++ b/core/storage/pager.rs @@ -663,7 +663,7 @@ impl Pager { } #[instrument(skip_all, level = Level::INFO)] - fn maybe_allocate_page1(&self) -> Result> { + pub fn maybe_allocate_page1(&self) -> Result> { if self.db_state.load(Ordering::SeqCst) < DB_STATE_INITIALIZED { if let Ok(_lock) = self.init_lock.try_lock() { match ( diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index 1ec6d9f0f..b00313225 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -1944,6 +1944,8 @@ pub fn op_transaction( if let Some(mv_store) = &mv_store { if state.mv_tx_id.is_none() { + // We allocate the first page lazily in the first transaction. + return_if_io!(pager.maybe_allocate_page1()); let tx_id = mv_store.begin_tx(); conn.mv_transactions.borrow_mut().push(tx_id); state.mv_tx_id = Some(tx_id);