From 3406676abdb0838d4ad5f671bdb7ca7ea1b50e94 Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Thu, 12 Oct 2023 22:53:27 +0300 Subject: [PATCH] Check if walredo pipe was recreated by some other backend before klilling walredo process --- pageserver/src/walredo.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pageserver/src/walredo.rs b/pageserver/src/walredo.rs index 23433fa694..d259fdd749 100644 --- a/pageserver/src/walredo.rs +++ b/pageserver/src/walredo.rs @@ -267,6 +267,7 @@ impl PostgresRedoManager { let mut n_attempts = 0u32; loop { let mut proc = self.stdin.lock().unwrap(); + let stdin_fd = proc.as_mut().unwrap().stdin.as_raw_fd(); let lock_time = Instant::now(); // launch the WAL redo process on first use @@ -333,7 +334,9 @@ impl PostgresRedoManager { // and hence the current `apply_wal_records()` calls will observe // `output.stdout.as_raw_fd() != stdout_fd` . if let Some(proc) = self.stdin.lock().unwrap().take() { - proc.child.kill_and_wait(); + if stdin_fd == proc.stdin.as_raw_fd() { + proc.child.kill_and_wait(); + } } } else if n_attempts != 0 { info!(n_attempts, "retried walredo succeeded");