everything compiles

This commit is contained in:
Christian Schwarz
2025-07-11 15:39:12 +02:00
parent 2156d02658
commit a3e05b5abf
7 changed files with 19 additions and 35 deletions

View File

@@ -154,7 +154,7 @@ impl Cli {
fn main() -> Result<()> {
let cli = Cli::parse();
let scenario = failpoint_support::init();
failpoint_support::init().unwrap();
// For historical reasons, the main thread that processes the config and launches postgres
// is synchronous, but we always have this tokio runtime available and we "enter" it so
@@ -201,8 +201,6 @@ fn main() -> Result<()> {
let exit_code = compute_node.run()?;
scenario.teardown();
deinit_and_exit(exit_code);
}

View File

@@ -173,6 +173,12 @@ pub fn has_failpoints() -> bool {
cfg!(feature = "testing") || std::env::var("FAILPOINTS").is_ok()
}
pub fn list() -> Vec<(impl std::fmt::Display, impl std::fmt::Display)> {
FAILPOINTS.read().iter().map(|(name, config)| {
(name.clone(), format!("{config:?}"))
}).collect::<Vec<_>>()
}
/// Execute a failpoint with optional context
pub fn failpoint(name: &str, context: Option<&FailpointContext>) -> Either<FailpointResult, Pin<Box<dyn Future<Output = FailpointResult> + Send>>> {
failpoint_with_cancellation(name, context, &CancellationToken::new())

View File

@@ -16,27 +16,14 @@ macro_rules! pausable_failpoint {
};
}
/// use with neon_failpoint::configure_failpoint("$name", "sleep(2000)")
///
/// The effect is similar to a "sleep(2000)" action, i.e. we sleep for the
/// specified time (in milliseconds). The main difference is that we use async
/// tokio sleep function. Another difference is that we print lines to the log,
/// which can be useful in tests to check that the failpoint was hit.
///
/// Optionally pass a cancellation token, and this failpoint will drop out of
/// its sleep when the cancellation token fires. This is useful for testing
/// cases where we would like to block something, but test its clean shutdown behavior.
/// Mere forward to neon_failpoint::failpoint
#[macro_export]
macro_rules! __failpoint_sleep_millis_async {
($name:literal) => {{
if cfg!(feature = "testing") {
::neon_failpoint::failpoint($name, None).await;
}
let _ = ::neon_failpoint::pausable_failpoint!($name);
}};
($name:literal, $cancel:expr) => {{
if cfg!(feature = "testing") {
::neon_failpoint::failpoint_with_cancellation($name, None, $cancel).await;
}
let _ = ::neon_failpoint::pausable_failpoint!($name, $cancel);
}};
}
pub use __failpoint_sleep_millis_async as sleep_millis_async;

View File

@@ -68,7 +68,7 @@ const FEATURES: &[&str] = &[
fn version() -> String {
format!(
"{GIT_VERSION} failpoints: {}, features: {:?}",
fail::has_failpoints(),
neon_failpoint::has_failpoints(),
FEATURES,
)
}
@@ -84,7 +84,7 @@ fn main() -> anyhow::Result<()> {
}
// Initialize up failpoints support
let scenario = failpoint_support::init();
failpoint_support::init().unwrap();
let workdir = arg_matches
.get_one::<String>("workdir")
@@ -221,7 +221,6 @@ fn main() -> anyhow::Result<()> {
start_pageserver(launch_ts, conf, ignored, otel_guard).context("Failed to start pageserver")?;
scenario.teardown();
Ok(())
}
@@ -366,16 +365,9 @@ fn start_pageserver(
// If any failpoints were set from FAILPOINTS environment variable,
// print them to the log for debugging purposes
let failpoints = fail::list();
if !failpoints.is_empty() {
info!(
"started with failpoints: {}",
failpoints
.iter()
.map(|(name, actions)| format!("{name}={actions}"))
.collect::<Vec<String>>()
.join(";")
)
let failpoints = neon_failpoint::list();
for (name, actions) in failpoints {
info!("starting with failpoint: {name} {actions}");
}
// Create and lock PID file. This ensures that there cannot be more than one

View File

@@ -336,7 +336,7 @@ async fn page_service_conn_main(
let default_timeout_ms = 10 * 60 * 1000; // 10 minutes by default
let socket_timeout_ms = (|| {
fail::fail_point_sync!("simulated-bad-compute-connection", |avg_timeout_ms| {
fail::fail_point_sync!("simulated-bad-compute-connection", |avg_timeout_ms: Option<String>| {
// Exponential distribution for simulating
// poor network conditions, expect about avg_timeout_ms to be around 15
// in tests

View File

@@ -5184,7 +5184,7 @@ impl Timeline {
*self.applied_gc_cutoff_lsn.read(),
);
neon_failpoint::fail_point_sync!("checkpoint-before-saving-metadata", |x| bail!(
neon_failpoint::fail_point_sync!("checkpoint-before-saving-metadata", |x: Option<String>| bail!(
"{}",
x.unwrap()
));

View File

@@ -66,6 +66,7 @@ use utils::lsn::Lsn;
use utils::shard::ShardIndex;
use utils::sync::gate::{Gate, GateGuard};
use utils::{failpoint_support, pausable_failpoint};
use neon_failpoint as fail;
use crate::background_node_operations::{
Delete, Drain, Fill, MAX_RECONCILES_PER_OPERATION, Operation, OperationError, OperationHandler,
@@ -6026,7 +6027,7 @@ impl Service {
tenant_id: TenantId,
split_req: TenantShardSplitRequest,
) -> Result<ShardSplitAction, ApiError> {
fail::fail_point!("shard-split-validation", |_| Err(ApiError::BadRequest(
fail::fail_point_sync!("shard-split-validation", |_| Err(ApiError::BadRequest(
anyhow::anyhow!("failpoint")
)));