From 188f67e1dffe119b6468cd5e0d86360fd1b4b6e4 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 23 Oct 2023 16:51:38 +0100 Subject: [PATCH] pageserver: forward compat: be tolerant of deletion marker in `timelines/` (#5632) ## Problem https://github.com/neondatabase/neon/pull/5580 will move the remote deletion marker into the `timelines/` path. This would cause old pageserver code to fail loading the tenant due to an apparently invalid timeline ID. That would be a problem if we had to roll back after deploying #5580 ## Summary of changes If a `deleted` file is in `timelines/` just ignore it. --- pageserver/src/tenant/remote_timeline_client/download.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pageserver/src/tenant/remote_timeline_client/download.rs b/pageserver/src/tenant/remote_timeline_client/download.rs index ef8d217be4..ca6e3293d6 100644 --- a/pageserver/src/tenant/remote_timeline_client/download.rs +++ b/pageserver/src/tenant/remote_timeline_client/download.rs @@ -18,7 +18,7 @@ use crate::config::PageServerConf; use crate::tenant::remote_timeline_client::{remote_layer_path, remote_timelines_path}; use crate::tenant::storage_layer::LayerFileName; use crate::tenant::timeline::span::debug_assert_current_span_has_tenant_and_timeline_id; -use crate::tenant::Generation; +use crate::tenant::{Generation, TENANT_DELETED_MARKER_FILE_NAME}; use remote_storage::{DownloadError, GenericRemoteStorage}; use utils::crashsafe::path_with_suffix_extension; use utils::id::{TenantId, TimelineId}; @@ -190,6 +190,12 @@ pub async fn list_remote_timelines( let mut timeline_ids = HashSet::new(); for timeline_remote_storage_key in timelines { + if timeline_remote_storage_key.object_name() == Some(TENANT_DELETED_MARKER_FILE_NAME) { + // A `deleted` key within `timelines/` is a marker file, not a timeline. Ignore it. + // This code will be removed in https://github.com/neondatabase/neon/pull/5580 + continue; + } + let object_name = timeline_remote_storage_key.object_name().ok_or_else(|| { anyhow::anyhow!("failed to get timeline id for remote tenant {tenant_id}") })?;