diff --git a/rust/log-service/src/lib.rs b/rust/log-service/src/lib.rs index bd1b5793edb..22f13019db5 100644 --- a/rust/log-service/src/lib.rs +++ b/rust/log-service/src/lib.rs @@ -1452,13 +1452,24 @@ impl LogServer { Arc::clone(&storage), target_prefix, ); + let new_manifest = log_reader + .manifest() + .await + .map_err(|err| { + Status::new( + err.code().into(), + format!("Unable to read copied manifest: {}", err), + ) + })? + .ok_or_else(|| Status::internal("Unable to find copied manifest"))?; + let first_copied_offset = new_manifest.oldest_timestamp(); + if offset < first_copied_offset { + return Err(Status::internal(format!( + "Compaction cursor [{offset:?}] is behind start of manifest [{first_copied_offset:?}]", + ))); + } // This is the next record to insert, so we'll have to adjust downwards. - let max_offset = log_reader.next_write_timestamp().await.map_err(|err| { - Status::new( - err.code().into(), - format!("Failed to read copied log: {}", err), - ) - })?; + let max_offset = new_manifest.next_write_timestamp(); if max_offset < offset { return Err(Status::new( chroma_error::ErrorCodes::Internal.into(),