Skip to content

Commit

Permalink
fix: Properly reset wal segment writer (#13468)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena authored Jul 10, 2024
1 parent 4220737 commit 6ea83b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/storage/wal/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ type streamSegment struct {
}

func (s *streamSegment) Reset() {
for i := range s.entries {
s.entries[i] = nil
}
s.lbls = nil
s.tenantID = ""
s.maxt = 0
s.entries = s.entries[:0]
}

Expand Down Expand Up @@ -102,7 +108,6 @@ func (b *SegmentWriter) getOrCreateStream(id streamID, lbls labels.Labels) *stre
lbls = labels.NewBuilder(lbls).Set(tenantLabel, id.tenant).Labels()
}
s = streamSegmentPool.Get().(*streamSegment)
s.Reset()
s.lbls = lbls
s.tenantID = id.tenant
b.streams[id] = s
Expand Down Expand Up @@ -265,6 +270,7 @@ func (b *SegmentWriter) WriteTo(w io.Writer) (int64, error) {
func (b *SegmentWriter) Reset() {
for _, s := range b.streams {
s := s
s.Reset()
streamSegmentPool.Put(s)
}
b.streams = make(map[streamID]*streamSegment, 64)
Expand Down

0 comments on commit 6ea83b4

Please sign in to comment.