diff --git a/simulator/generation/property.rs b/simulator/generation/property.rs index d93a7e9a1..18a6a73bf 100644 --- a/simulator/generation/property.rs +++ b/simulator/generation/property.rs @@ -11,6 +11,7 @@ use crate::{ Create, Delete, Drop, Insert, Query, Select, }, table::SimValue, + FAULT_ERROR_MSG, }, runner::env::SimulatorEnv, }; @@ -489,7 +490,14 @@ impl Property { query_clone.shadow(env); Ok(true) } - Err(err) => Err(LimboError::InternalError(format!("{}", err))), + Err(err) => { + let msg = format!("{}", err); + if msg.contains(FAULT_ERROR_MSG) { + Ok(true) + } else { + Err(LimboError::InternalError(msg)) + } + } } }), }; diff --git a/simulator/model/mod.rs b/simulator/model/mod.rs index a29f56382..e68355ee4 100644 --- a/simulator/model/mod.rs +++ b/simulator/model/mod.rs @@ -1,2 +1,4 @@ pub mod query; pub mod table; + +pub(crate) const FAULT_ERROR_MSG: &str = "Injected fault"; diff --git a/simulator/runner/file.rs b/simulator/runner/file.rs index 12eb10f30..21511a7c3 100644 --- a/simulator/runner/file.rs +++ b/simulator/runner/file.rs @@ -7,6 +7,8 @@ use rand::Rng as _; use rand_chacha::ChaCha8Rng; use tracing::{instrument, Level}; use turso_core::{CompletionType, File, Result}; + +use crate::model::FAULT_ERROR_MSG; pub(crate) struct SimulatorFile { pub(crate) inner: Arc, pub(crate) fault: Cell, @@ -88,7 +90,7 @@ impl File for SimulatorFile { fn lock_file(&self, exclusive: bool) -> Result<()> { if self.fault.get() { return Err(turso_core::LimboError::InternalError( - "Injected fault".into(), + FAULT_ERROR_MSG.into(), )); } self.inner.lock_file(exclusive) @@ -97,7 +99,7 @@ impl File for SimulatorFile { fn unlock_file(&self) -> Result<()> { if self.fault.get() { return Err(turso_core::LimboError::InternalError( - "Injected fault".into(), + FAULT_ERROR_MSG.into(), )); } self.inner.unlock_file() @@ -113,7 +115,7 @@ impl File for SimulatorFile { tracing::debug!("pread fault"); self.nr_pread_faults.set(self.nr_pread_faults.get() + 1); return Err(turso_core::LimboError::InternalError( - "Injected fault".into(), + FAULT_ERROR_MSG.into(), )); } if let Some(latency) = self.generate_latency_duration() { @@ -148,7 +150,7 @@ impl File for SimulatorFile { tracing::debug!("pwrite fault"); self.nr_pwrite_faults.set(self.nr_pwrite_faults.get() + 1); return Err(turso_core::LimboError::InternalError( - "Injected fault".into(), + FAULT_ERROR_MSG.into(), )); } if let Some(latency) = self.generate_latency_duration() { @@ -178,7 +180,7 @@ impl File for SimulatorFile { tracing::debug!("sync fault"); self.nr_sync_faults.set(self.nr_sync_faults.get() + 1); return Err(turso_core::LimboError::InternalError( - "Injected fault".into(), + FAULT_ERROR_MSG.into(), )); } if let Some(latency) = self.generate_latency_duration() { diff --git a/simulator/runner/io.rs b/simulator/runner/io.rs index b3c823125..41a140675 100644 --- a/simulator/runner/io.rs +++ b/simulator/runner/io.rs @@ -7,7 +7,7 @@ use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; use turso_core::{Clock, Instant, OpenFlags, PlatformIO, Result, IO}; -use crate::runner::file::SimulatorFile; +use crate::{model::FAULT_ERROR_MSG, runner::file::SimulatorFile}; pub(crate) struct SimulatorIO { pub(crate) inner: Box, @@ -104,7 +104,7 @@ impl IO for SimulatorIO { self.nr_run_once_faults .replace(self.nr_run_once_faults.get() + 1); return Err(turso_core::LimboError::InternalError( - "Injected fault".into(), + FAULT_ERROR_MSG.into(), )); } self.inner.run_once()?;