mirror of
https://github.com/prometheus/prometheus.git
synced 2026-04-21 06:09:22 -04:00
fix: filter deleted entries
Signed-off-by: x1unix <9203548+x1unix@users.noreply.github.com>
This commit is contained in:
parent
3bf8f550b9
commit
ecaee0923c
2 changed files with 8 additions and 4 deletions
|
|
@ -777,7 +777,7 @@ func (db *DB) truncate(mint int64) error {
|
|||
AtIndex: last,
|
||||
BatchSize: db.opts.CheckpointBatchSize,
|
||||
ActiveSeries: db.series.Iterate(),
|
||||
DeletedSeries: deletedSeriesIter(db.deleted),
|
||||
DeletedSeries: deletedSeriesIter(db.deleted, last),
|
||||
})
|
||||
} else {
|
||||
_, err = wlog.Checkpoint(db.logger, db.wal, first, last, db.keepSeriesInWALCheckpointFn(last), mint, db.opts.EnableSTStorage)
|
||||
|
|
|
|||
|
|
@ -384,11 +384,15 @@ func (s *stripeSeries) Iterate() iter.Seq[ActiveSeries] {
|
|||
}
|
||||
|
||||
// deletedSeriesIter returns an iterator over deleted series from the given map.
|
||||
func deletedSeriesIter(m map[chunks.HeadSeriesRef]deletedRefMeta) iter.Seq[DeletedSeries] {
|
||||
// Only series whose lastSegment is greater than last are emitted, matching the
|
||||
// filtering behaviour of [wlog.Checkpoint] keep function.
|
||||
func deletedSeriesIter(m map[chunks.HeadSeriesRef]deletedRefMeta, last int) iter.Seq[DeletedSeries] {
|
||||
return func(yield func(DeletedSeries) bool) {
|
||||
for ref, meta := range m {
|
||||
if !yield(deletedSeries{ref: ref, labels: meta.labels}) {
|
||||
return
|
||||
if meta.lastSegment > last {
|
||||
if !yield(deletedSeries{ref: ref, labels: meta.labels}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue