From ad5eaa6027166b41e6485c49c7ea496e7c6515f0 Mon Sep 17 00:00:00 2001 From: Thang Pham Date: Thu, 5 May 2022 10:53:10 -0400 Subject: [PATCH] Use node's LSN for read-only nodes (#1642) Fixes #1410. --- zenith/src/main.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/zenith/src/main.rs b/zenith/src/main.rs index ff2beec463..87bb5f3f60 100644 --- a/zenith/src/main.rs +++ b/zenith/src/main.rs @@ -683,13 +683,21 @@ fn handle_pg(pg_match: &ArgMatches, env: &local_env::LocalEnv) -> Result<()> { .iter() .filter(|((node_tenant_id, _), _)| node_tenant_id == &tenant_id) { - // FIXME: This shows the LSN at the end of the timeline. It's not the - // right thing to do for read-only nodes that might be anchored at an - // older point in time, or following but lagging behind the primary. - let lsn_str = timeline_infos - .get(&node.timeline_id) - .and_then(|bi| bi.local.as_ref().map(|l| l.last_record_lsn.to_string())) - .unwrap_or_else(|| "?".to_string()); + let lsn_str = match node.lsn { + None => { + // -> primary node + // Use the LSN at the end of the timeline. + timeline_infos + .get(&node.timeline_id) + .and_then(|bi| bi.local.as_ref().map(|l| l.last_record_lsn.to_string())) + .unwrap_or_else(|| "?".to_string()) + } + Some(lsn) => { + // -> read-only node + // Use the node's LSN. + lsn.to_string() + } + }; let branch_name = timeline_name_mappings .get(&ZTenantTimelineId::new(tenant_id, node.timeline_id))