Never expect the replica iterators to be sorted (#538)

This commit is contained in:
Toni Spets
2023-12-18 13:27:50 +02:00
committed by GitHub
parent 1af88c4052
commit 0a7f6e9345
5 changed files with 13 additions and 17 deletions

View File

@@ -1302,10 +1302,15 @@ func (r *Replica) walSegmentMap(ctx context.Context, generation string, minIndex
}
defer itr.Close()
m := make(map[int][]int64)
a := []WALSegmentInfo{}
for itr.Next() {
info := itr.WALSegment()
a = append(a, itr.WALSegment())
}
sort.Sort(WALSegmentInfoSlice(a))
m := make(map[int][]int64)
for _, info := range a {
// Exit if we go past the max timestamp or index.
if !maxTimestamp.IsZero() && info.CreatedAt.After(maxTimestamp) {
break // after max timestamp, skip