From f9839a0dd931181dd849eb4ee2987fcc93d5e61a Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Thu, 4 May 2023 09:23:49 +0200 Subject: [PATCH] import_basebackup_from_tar: don't load local layers twice (#4111) PR #4104 removed these bits as part of a revert of a larger change. follow-up to https://github.com/neondatabase/neon/pull/4104#discussion_r1180444952 --- Let's not merge this before the release. --- pageserver/src/tenant.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index 5cfc466111..d69d5e4b45 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -271,7 +271,10 @@ impl UninitializedTimeline<'_> { .await .context("Failed to flush after basebackup import")?; - self.initialize(ctx) + // Initialize without loading the layer map. We started with an empty layer map, and already + // updated it for the layers that we created during the import. + let mut timelines = self.owning_tenant.timelines.lock().unwrap(); + self.initialize_with_lock(ctx, &mut timelines, false, true) } fn raw_timeline(&self) -> anyhow::Result<&Arc> { @@ -2352,6 +2355,8 @@ impl Tenant { ) })?; + // Initialize the timeline without loading the layer map, because we already updated the layer + // map above, when we imported the datadir. let timeline = { let mut timelines = self.timelines.lock().unwrap(); raw_timeline.initialize_with_lock(ctx, &mut timelines, false, true)?