improve XXX above remove_dir_all regarding atomicity

With this PR, we're now atomic, if remote storage is configured.
This commit is contained in:
Christian Schwarz
2023-05-03 19:38:05 +02:00
parent 30ea7b141b
commit 08558b83ed

View File

@@ -1446,8 +1446,12 @@ impl Tenant {
Err(anyhow::anyhow!("failpoint: timeline-delete-before-rm"))?
});
// XXX make this atomic so that, if we crash-mid-way, the timeline won't be picked up
// with some layers missing.
// NB: This need not be atomic because the deleted flag in the IndexPart
// will be observed during tenant/timeline load. The deletion will be resumed there.
//
// For configurations without remote storage, we tolerate that we're not crash-safe here.
// The timeline may come up Active but with missing layer files, in such setups.
// See https://github.com/neondatabase/neon/pull/3919#issuecomment-1531726720
std::fs::remove_dir_all(&local_timeline_directory).with_context(|| {
format!(
"Failed to remove local timeline directory '{}'",