From fcd9f294e73487f2df7738e0f7b2bc68fe3d7837 Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 16 Feb 2026 17:34:19 -0600 Subject: [PATCH] Don't call init reducer in spacetime generate (#4312) # Description of Changes Fixes #3492. # Expected complexity level and risk 1 # Testing - [ ] - [ ] --- crates/core/src/host/host_controller.rs | 37 +++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/crates/core/src/host/host_controller.rs b/crates/core/src/host/host_controller.rs index 58932f5df..678f0b50b 100644 --- a/crates/core/src/host/host_controller.rs +++ b/crates/core/src/host/host_controller.rs @@ -338,8 +338,8 @@ impl HostController { /// /// This is not necessary during hotswap publishes, /// as the automigration planner and executor accomplish the same validity checks. - pub async fn check_module_validity(&self, database: Database, program: Program) -> anyhow::Result> { - Host::try_init_in_memory_to_check( + pub async fn check_module_validity(&self, database: Database, program: Program) -> anyhow::Result<()> { + let (program, launched) = Host::try_init_in_memory_to_check( &self.runtimes, self.page_pool.clone(), database, @@ -352,7 +352,14 @@ impl HostController { self.db_cores.take(), self.bsatn_rlb_pool.clone(), ) - .await + .await?; + + let call_result = launched.module_host.init_database(program).await?; + if let Some(call_result) = call_result { + Result::from(call_result)?; + } + + Ok(()) } /// Run a computation on the [`RelationalDB`] of a [`ModuleHost`] managed by @@ -1012,8 +1019,7 @@ impl Host { }) } - /// Construct an in-memory instance of `database` running `program`, - /// initialize it, then immediately destroy it. + /// Construct an in-memory instance of `database` running `program`. /// /// This is used during an initial, fresh publish operation /// in order to check the `program`'s validity as a module, @@ -1029,7 +1035,7 @@ impl Host { program: Program, core: AllocatedJobCore, bsatn_rlb_pool: BsatnRowListBuilderPool, - ) -> anyhow::Result> { + ) -> anyhow::Result<(Program, LaunchedModule)> { let (db, _connected_clients) = RelationalDB::open( database.database_identity, database.owner_identity, @@ -1039,7 +1045,7 @@ impl Host { page_pool, )?; - let (program, launched) = launch_module( + launch_module( database, 0, program, @@ -1054,14 +1060,7 @@ impl Host { core, bsatn_rlb_pool, ) - .await?; - - let call_result = launched.module_host.init_database(program).await?; - if let Some(call_result) = call_result { - Result::from(call_result)?; - } - - Ok(launched.module_host.info) + .await } /// Attempt to replace this [`Host`]'s [`ModuleHost`] with a new one running @@ -1278,8 +1277,12 @@ pub(crate) async fn extract_schema_with_pools( }; let core = AllocatedJobCore::default(); - let module_info = - Host::try_init_in_memory_to_check(runtimes, page_pool, database, program, core, bsatn_rlb_pool).await?; + // Limit the scope of the launched module just to this block. + let module_info = { + let (_, launched) = + Host::try_init_in_memory_to_check(runtimes, page_pool, database, program, core, bsatn_rlb_pool).await?; + launched.module_host.info + }; // this should always succeed, but sometimes it doesn't let module_def = match Arc::try_unwrap(module_info) { Ok(info) => Arc::try_unwrap(info.module_def).unwrap_or_else(|module_def| (*module_def).clone()),