Skip to content

Commit dc65e79

Browse files
committed
[ENH] Add a lower bound to the scout logs response.
This allows one scout-logs request to know everything that's on the log. It's necessary for the range to be everything pull-logs can access.
1 parent b7fa0d7 commit dc65e79

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

go/pkg/log/server/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@ func (s *logServer) ScoutLogs(ctx context.Context, req *logservicepb.ScoutLogsRe
5454
if err != nil {
5555
return
5656
}
57+
var start int64
5758
var limit int64
58-
_, limit, err = s.lr.GetBoundsForCollection(ctx, collectionID.String())
59+
start, limit, err = s.lr.GetBoundsForCollection(ctx, collectionID.String())
5960
if err != nil {
6061
return
6162
}
6263
// +1 to convert from the (] bound to a [) bound.
6364
res = &logservicepb.ScoutLogsResponse{
65+
FirstUncompactedRecordOffset: int64(start + 1),
6466
FirstUninsertedRecordOffset: int64(limit + 1),
6567
}
66-
trace_log.Info("Scouted Logs", zap.Int64("limit", int64(limit + 1)), zap.String("collectionId", req.CollectionId))
68+
trace_log.Info("Scouted Logs", zap.Int64("start", int64(start + 1)), zap.Int64("limit", int64(limit + 1)), zap.String("collectionId", req.CollectionId))
6769
return
6870
}
6971

idl/chromadb/proto/logservice.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ message ScoutLogsResponse {
2424
reserved 1;
2525
// The next record to insert will have this offset.
2626
int64 first_uninserted_record_offset = 2;
27+
// The oldest record on the log will have this offset.
28+
int64 first_uncompacted_record_offset = 3;
2729
}
2830

2931
message PullLogsRequest {

rust/log-service/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,18 +716,24 @@ impl LogService for LogServer {
716716
Arc::clone(&self.storage),
717717
prefix,
718718
);
719-
let limit_position = match log_reader.maximum_log_position().await {
720-
Ok(limit_position) => limit_position,
719+
let (start_position, limit_position) = match log_reader.manifest().await {
720+
Ok(Some(manifest)) => (
721+
manifest.minimum_log_position(),
722+
manifest.maximum_log_position(),
723+
),
724+
Ok(None) => (LogPosition::from_offset(0), LogPosition::from_offset(1)),
721725
Err(err) => {
722726
if err.code() == chroma_error::ErrorCodes::FailedPrecondition {
723-
LogPosition::from_offset(1)
727+
(LogPosition::from_offset(1), LogPosition::from_offset(1))
724728
} else {
725729
return Err(Status::new(err.code().into(), err.to_string()));
726730
}
727731
}
728732
};
733+
let start_offset = start_position.offset() as i64;
729734
let limit_offset = limit_position.offset() as i64;
730735
Ok(Response::new(ScoutLogsResponse {
736+
first_uncompacted_record_offset: start_offset,
731737
first_uninserted_record_offset: limit_offset,
732738
}))
733739
}

rust/wal3/src/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl Snapshot {
276276
},
277277
(Some(f), None) => f,
278278
(None, Some(s)) => s,
279-
(None, None) => LogPosition::default(),
279+
(None, None) => LogPosition::from_offset(1),
280280
}
281281
}
282282

0 commit comments

Comments
 (0)