Skip to content

Commit

Permalink
feat(v2): extend period for truncation, do not truncate all blocks (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-p authored Sep 10, 2024
1 parent b4ad60d commit 0157bd9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/experiment/metastore/metastore_hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (m *Metastore) cleanupLoop() {
if m.raft.State() != raft.Leader {
continue
}
timestamp := uint64(time.Now().Add(-12 * time.Hour).UnixMilli())
timestamp := uint64(time.Now().Add(-7 * 24 * time.Hour).UnixMilli())
req := &raftlogpb.TruncateCommand{Timestamp: timestamp}
_, _, err := applyCommand[*raftlogpb.TruncateCommand, *anypb.Any](m.raft, req, m.config.Raft.ApplyTimeout)
if err != nil {
Expand Down Expand Up @@ -88,6 +88,9 @@ func truncateSegmentsBefore(
defer shard.segmentsMutex.Unlock()

for k, segment := range shard.segments {
if segment.CompactionLevel > 2 {
continue
}
if ulid.MustParse(segment.Id).Time() < t {
if err = bucket.Delete([]byte(segment.Id)); err != nil {
_ = level.Error(log).Log("msg", "failed to delete stale segments", "err", err)
Expand Down

0 comments on commit 0157bd9

Please sign in to comment.