mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-08 22:12:56 +00:00
## Problem see https://github.com/neondatabase/neon/issues/8070 ## Summary of changes the neon_local subcommands to - start neon - start pageserver - start safekeeper - start storage controller get a new option -t=xx or --start-timeout=xx which allows to specify a longer timeout in seconds we wait for the process start. This is useful in test cases where the pageserver has to read a lot of layer data, like in pagebench test cases. In addition we exploit the new timeout option in the python test infrastructure (python fixtures) and modify the flaky testcase to increase the timeout from 10 seconds to 1 minute. Example from the test execution ```bash RUST_BACKTRACE=1 NEON_ENV_BUILDER_USE_OVERLAYFS_FOR_SNAPSHOTS=1 DEFAULT_PG_VERSION=15 BUILD_TYPE=release ./scripts/pytest test_runner/performance/pageserver/pagebench/test_pageserver_max_throughput_getpage_at_latest_lsn.py ... 2024-06-19 09:29:34.590 INFO [neon_fixtures.py:1513] Running command "/instance_store/neon/target/release/neon_local storage_controller start --start-timeout=60s" 2024-06-19 09:29:36.365 INFO [broker.py:34] starting storage_broker to listen incoming connections at "127.0.0.1:15001" 2024-06-19 09:29:36.365 INFO [neon_fixtures.py:1513] Running command "/instance_store/neon/target/release/neon_local pageserver start --id=1 --start-timeout=60s" 2024-06-19 09:29:36.366 INFO [neon_fixtures.py:1513] Running command "/instance_store/neon/target/release/neon_local safekeeper start 1 --start-timeout=60s" ```
64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
//! Code to manage the storage broker
|
|
//!
|
|
//! In the local test environment, the data for each safekeeper is stored in
|
|
//!
|
|
//! ```text
|
|
//! .neon/safekeepers/<safekeeper id>
|
|
//! ```
|
|
use std::time::Duration;
|
|
|
|
use anyhow::Context;
|
|
|
|
use camino::Utf8PathBuf;
|
|
|
|
use crate::{background_process, local_env};
|
|
|
|
pub async fn start_broker_process(
|
|
env: &local_env::LocalEnv,
|
|
retry_timeout: &Duration,
|
|
) -> anyhow::Result<()> {
|
|
let broker = &env.broker;
|
|
let listen_addr = &broker.listen_addr;
|
|
|
|
print!("Starting neon broker at {}", listen_addr);
|
|
|
|
let args = [format!("--listen-addr={listen_addr}")];
|
|
|
|
let client = reqwest::Client::new();
|
|
background_process::start_process(
|
|
"storage_broker",
|
|
&env.base_data_dir,
|
|
&env.storage_broker_bin(),
|
|
args,
|
|
[],
|
|
background_process::InitialPidFile::Create(storage_broker_pid_file_path(env)),
|
|
retry_timeout,
|
|
|| async {
|
|
let url = broker.client_url();
|
|
let status_url = url.join("status").with_context(|| {
|
|
format!("Failed to append /status path to broker endpoint {url}")
|
|
})?;
|
|
let request = client
|
|
.get(status_url)
|
|
.build()
|
|
.with_context(|| format!("Failed to construct request to broker endpoint {url}"))?;
|
|
match client.execute(request).await {
|
|
Ok(resp) => Ok(resp.status().is_success()),
|
|
Err(_) => Ok(false),
|
|
}
|
|
},
|
|
)
|
|
.await
|
|
.context("Failed to spawn storage_broker subprocess")?;
|
|
Ok(())
|
|
}
|
|
|
|
pub fn stop_broker_process(env: &local_env::LocalEnv) -> anyhow::Result<()> {
|
|
background_process::stop_process(true, "storage_broker", &storage_broker_pid_file_path(env))
|
|
}
|
|
|
|
fn storage_broker_pid_file_path(env: &local_env::LocalEnv) -> Utf8PathBuf {
|
|
Utf8PathBuf::from_path_buf(env.base_data_dir.join("storage_broker.pid"))
|
|
.expect("non-Unicode path")
|
|
}
|