diff --git a/core/storage/wal.rs b/core/storage/wal.rs index 39fb79e46..ba4ecbbfc 100644 --- a/core/storage/wal.rs +++ b/core/storage/wal.rs @@ -1956,7 +1956,7 @@ impl WalFile { return_if_io!(self.truncate_log()); } if mode.should_restart_log() { - Self::unlock(&self.shared, None); + Self::unlock_after_restart(&self.shared, None); } let mut checkpoint_result = { let CheckpointState::Truncate { @@ -2129,7 +2129,10 @@ impl WalFile { let shared = self.shared.clone(); move |result| { if let Err(err) = result { - Self::unlock(&shared, Some(&LimboError::InternalError(err.to_string()))); + Self::unlock_after_restart( + &shared, + Some(&LimboError::InternalError(err.to_string())), + ); } else { tracing::trace!("WAL file truncated to 0 B"); } @@ -2137,7 +2140,7 @@ impl WalFile { }); let c = file .truncate(0, c) - .inspect_err(|e| Self::unlock(&self.shared, Some(e)))?; + .inspect_err(|e| Self::unlock_after_restart(&self.shared, Some(e)))?; *truncate_sent = true; io_yield_one!(c); } else if !*sync_sent { @@ -2145,19 +2148,23 @@ impl WalFile { let c = file .sync(Completion::new_sync(move |result| { if let Err(err) = result { - Self::unlock(&shared, Some(&LimboError::InternalError(err.to_string()))); + Self::unlock_after_restart( + &shared, + Some(&LimboError::InternalError(err.to_string())), + ); } else { tracing::trace!("WAL file synced after reset/truncation"); } })) - .inspect_err(|e| Self::unlock(&self.shared, Some(e)))?; + .inspect_err(|e| Self::unlock_after_restart(&self.shared, Some(e)))?; *sync_sent = true; io_yield_one!(c); } Ok(IOResult::Done(())) } - fn unlock(shared: &Arc>, e: Option<&LimboError>) { + // unlock shared read locks taken by RESTART/TRUNCATE checkpoint modes + fn unlock_after_restart(shared: &Arc>, e: Option<&LimboError>) { // release all read locks we just acquired, the caller will take care of the others let shared = shared.write(); for idx in 1..shared.read_locks.len() { diff --git a/tests/integration/query_processing/test_multi_thread.rs b/tests/integration/query_processing/test_multi_thread.rs index 73817be23..6054c7a32 100644 --- a/tests/integration/query_processing/test_multi_thread.rs +++ b/tests/integration/query_processing/test_multi_thread.rs @@ -23,7 +23,7 @@ fn test_schema_reprepare() { assert_eq!(err.to_string(), "Parse error: no such column: x"); break; } - r => panic!("unexpected response: {:?}", r), + r => panic!("unexpected response: {r:?}"), } }