satellite/metainfo: use ListStreamPositions

ListSegments loads all the segment data into memory, however this can
add up to a lot of data with inline segments and large objects.

Change-Id: I037738f0e70b810ecbea7d83b00ea7ca9eb90c7a
This commit is contained in:
Egon Elbre 2021-03-08 14:10:33 +02:00
parent 5bc0f3bf23
commit 981f1ca449
2 changed files with 3 additions and 1 deletions

View File

@ -205,6 +205,8 @@ type MetabaseDB interface {
GetLatestObjectLastSegment(ctx context.Context, opts metabase.GetLatestObjectLastSegment) (segment metabase.Segment, err error)
// ListSegments lists specified stream segments.
ListSegments(ctx context.Context, opts metabase.ListSegments) (result metabase.ListSegmentsResult, err error)
// ListStreamPositions lists specified stream segment positions.
ListStreamPositions(ctx context.Context, opts metabase.ListStreamPositions) (result metabase.ListStreamPositionsResult, err error)
// IterateObjectsAllVersions iterates through all versions of all objects.
IterateObjectsAllVersions(ctx context.Context, opts metabase.IterateObjects, fn func(context.Context, metabase.ObjectsIterator) error) (err error)
// IterateObjectsAllVersionsWithStatus iterates through all versions of all objects with specified status.

View File

@ -1694,7 +1694,7 @@ func (endpoint *Endpoint) ListSegments(ctx context.Context, req *pb.SegmentListR
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
}
result, err := endpoint.metainfo.metabaseDB.ListSegments(ctx, metabase.ListSegments{
result, err := endpoint.metainfo.metabaseDB.ListStreamPositions(ctx, metabase.ListStreamPositions{
StreamID: id,
Cursor: metabase.SegmentPosition{
Part: uint32(cursor.PartNumber),