some more review suggestions

This commit is contained in:
Dmitry Rodionov
2023-04-12 21:12:34 +03:00
parent 3ffdb196bf
commit d826cacc7d
3 changed files with 9 additions and 2 deletions

View File

@@ -643,6 +643,10 @@ impl RemoteTimelineClient {
UploadQueue::Stopped(stopped) => stopped,
};
assert!(
!stopped.last_uploaded_index_part.is_deleted,
"deleted flag already set"
);
stopped.last_uploaded_index_part.is_deleted = true;
stopped.last_uploaded_index_part.clone()
};

View File

@@ -87,7 +87,7 @@ impl IndexPart {
/// used to understand later versions.
///
/// Version is currently informative only.
const LATEST_VERSION: usize = 1;
const LATEST_VERSION: usize = 2;
pub const FILE_NAME: &'static str = "index_part.json";
pub fn new(

View File

@@ -19,9 +19,12 @@ pub(super) async fn upload_index_part<'a>(
timeline_id: TimelineId,
index_part: &'a IndexPart,
) -> anyhow::Result<()> {
tracing::trace!("uploading new index part");
fail_point!("before-upload-index", |_| {
bail!("failpoint before-upload-index")
});
let index_part_bytes = serde_json::to_vec(&index_part)
.context("Failed to serialize index part file into bytes")?;
let index_part_size = index_part_bytes.len();
@@ -31,7 +34,7 @@ pub(super) async fn upload_index_part<'a>(
.metadata_path(timeline_id, tenant_id)
.with_file_name(IndexPart::FILE_NAME);
let storage_path = conf.remote_path(&index_part_path)?;
tracing::info!("uploading new index part for {tenant_id}/{timeline_id}");
storage
.upload_storage_object(Box::new(index_part_bytes), index_part_size, &storage_path)
.await