[DNM] benchmark: add ability to force a walredo roundtrip even if in-proces is possible

This commit is contained in:
Christian Schwarz
2024-09-04 18:48:48 +00:00
parent 2b08a56f90
commit e3307851d7
2 changed files with 25 additions and 3 deletions

View File

@@ -5085,6 +5085,16 @@ impl Timeline {
img_lsn,
request_lsn,
);
if *crate::walredo::ADD_PROCESS_PING_TO_IN_PROCESS {
self.walredo_mgr
.as_ref()
.context("timeline has no walredo manager")
.map_err(PageReconstructError::WalRedo)?
.ping(self.pg_version)
.await
.unwrap();
}
Ok(img.clone())
} else {
Err(PageReconstructError::from(anyhow!(

View File

@@ -171,7 +171,8 @@ impl PostgresRedoManager {
if rec_neon != batch_neon {
let result = if batch_neon {
self.apply_batch_neon(key, lsn, img, &records[batch_start..i])
self.apply_batch_neon(key, lsn, img, &records[batch_start..i], pg_version)
.await
} else {
self.apply_batch_postgres(
key,
@@ -192,7 +193,8 @@ impl PostgresRedoManager {
}
// last batch
if batch_neon {
self.apply_batch_neon(key, lsn, img, &records[batch_start..])
self.apply_batch_neon(key, lsn, img, &records[batch_start..], pg_version)
.await
} else {
self.apply_batch_postgres(
key,
@@ -494,12 +496,13 @@ impl PostgresRedoManager {
///
/// Process a batch of WAL records using bespoken Neon code.
///
fn apply_batch_neon(
async fn apply_batch_neon(
&self,
key: Key,
lsn: Lsn,
base_img: Option<Bytes>,
records: &[(Lsn, NeonWalRecord)],
pg_version: u32,
) -> Result<Bytes, Error> {
let start_time = Instant::now();
@@ -529,6 +532,10 @@ impl PostgresRedoManager {
lsn
);
if *ADD_PROCESS_PING_TO_IN_PROCESS {
self.ping(pg_version).await.unwrap();
}
Ok(page.freeze())
}
@@ -545,6 +552,11 @@ impl PostgresRedoManager {
}
}
// add a walredo roundtrip to simulate latency overhead
pub(crate) static ADD_PROCESS_PING_TO_IN_PROCESS: Lazy<bool> = Lazy::new(|| {
utils::env::var("NEON_PAGESERVER_WALREDO_ADD_PROCESS_PING_TO_IN_PROCESS").unwrap_or(false)
});
#[cfg(test)]
mod tests {
use super::PostgresRedoManager;