Skip to content

Commit 4910550

Browse files
committed
[ENH] Record insertion time/count for wal3 dirty log.
This makes the wal3 dirty log record information that may be useful for determining which collections to compact or defer.
1 parent 504f581 commit 4910550

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

rust/log-service/src/lib.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::sync::Arc;
2-
use std::time::{Duration, Instant};
2+
use std::time::{Duration, Instant, SystemTime};
33

44
use bytes::Bytes;
55
use chroma_config::Configurable;
@@ -214,6 +214,8 @@ async fn get_log_from_handle<'a>(
214214
pub struct DirtyMarker {
215215
collection_id: CollectionUuid,
216216
log_position: LogPosition,
217+
reinsert_count: u64,
218+
initial_insertion_epoch_us: u64,
217219
}
218220

219221
///////////////////////////////////////////// MarkDirty ////////////////////////////////////////////
@@ -227,9 +229,15 @@ pub struct MarkDirty {
227229
#[async_trait::async_trait]
228230
impl wal3::MarkDirty for MarkDirty {
229231
async fn mark_dirty(&self, log_position: LogPosition) -> Result<(), wal3::Error> {
232+
let initial_insertion_epoch_us = SystemTime::now()
233+
.duration_since(SystemTime::UNIX_EPOCH)
234+
.map_err(|_| wal3::Error::Internal)?
235+
.as_micros() as u64;
230236
let dirty_marker = DirtyMarker {
231237
collection_id: self.collection_id,
232238
log_position,
239+
reinsert_count: 0,
240+
initial_insertion_epoch_us,
233241
};
234242
let dirty_marker_json = serde_json::to_string(&dirty_marker).map_err(|err| {
235243
tracing::error!("Failed to serialize dirty marker: {}", err);

0 commit comments

Comments
 (0)