Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip deletion of safekeeper data if done previously. #6766

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions safekeeper/src/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ pub struct SharedState {
/// when tli is inactive instead of having this flag.
active: bool,
last_removed_segno: XLogSegNo,
/// True if local and remote deletion has been done, allows to skip visiting
/// s3 on retries.
fully_deleted: bool,
}

impl SharedState {
Expand Down Expand Up @@ -155,6 +158,7 @@ impl SharedState {
wal_backup_active: false,
active: false,
last_removed_segno: 0,
fully_deleted: false,
})
}

Expand All @@ -174,6 +178,7 @@ impl SharedState {
wal_backup_active: false,
active: false,
last_removed_segno: 0,
fully_deleted: false,
})
}

Expand Down Expand Up @@ -482,6 +487,10 @@ impl Timeline {
shared_state: &mut MutexGuard<'_, SharedState>,
only_local: bool,
) -> Result<(bool, bool)> {
if shared_state.fully_deleted {
return Ok((false, false));
};

let was_active = shared_state.active;
self.cancel(shared_state);

Expand All @@ -496,6 +505,9 @@ impl Timeline {
wal_backup::delete_timeline(&self.ttid).await?;
}
let dir_existed = delete_dir(&self.timeline_dir).await?;
if !only_local {
shared_state.fully_deleted = true;
}
Ok((dir_existed, was_active))
}

Expand Down