From f8702d46256687648b95079ca63113de1d2791fa Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 15 Nov 2021 20:19:15 +0200 Subject: [PATCH] Fix checking for whether segment exists on a frozen in-memory layer. Ever since we've had frozen in-memory layers, having an 'end_lsn' no longer means that the layer has been dropped. Need to check the 'dropped' flag explicitly. This was reliably causing a failure on the new 'test_parallel_copy' test in https://github.com/zenithdb/zenith/pull/864. I'm not sure why it doesn't happen on main branch, but the bug is pretty straightforward when you see it. --- pageserver/src/layered_repository/inmemory_layer.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pageserver/src/layered_repository/inmemory_layer.rs b/pageserver/src/layered_repository/inmemory_layer.rs index 97a96a059e..04ff8a3193 100644 --- a/pageserver/src/layered_repository/inmemory_layer.rs +++ b/pageserver/src/layered_repository/inmemory_layer.rs @@ -247,9 +247,13 @@ impl Layer for InMemoryLayer { assert!(lsn >= self.start_lsn); // Is the requested LSN after the segment was dropped? - if let Some(end_lsn) = inner.end_lsn { - if lsn >= end_lsn { - return Ok(false); + if inner.dropped { + if let Some(end_lsn) = inner.end_lsn { + if lsn >= end_lsn { + return Ok(false); + } + } else { + panic!("dropped in-memory layer with no end LSN"); } }