mirror of https://github.com/prometheus/prometheus
tsdb/wal: some small refactoring for easier reading (#5930)
Signed-off-by: johncming <johncming@yahoo.com>pull/5937/head
parent
5e36aa1491
commit
7d43feb03f
|
@ -205,15 +205,16 @@ func NewSize(logger log.Logger, reg prometheus.Registerer, dir string, segmentSi
|
||||||
}
|
}
|
||||||
registerMetrics(reg, w)
|
registerMetrics(reg, w)
|
||||||
|
|
||||||
_, j, err := w.Segments()
|
_, last, err := w.Segments()
|
||||||
// Index of the Segment we want to open and write to.
|
|
||||||
writeSegmentIndex := 0
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "get segment range")
|
return nil, errors.Wrap(err, "get segment range")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Index of the Segment we want to open and write to.
|
||||||
|
writeSegmentIndex := 0
|
||||||
// If some segments already exist create one with a higher index than the last segment.
|
// If some segments already exist create one with a higher index than the last segment.
|
||||||
if j != -1 {
|
if last != -1 {
|
||||||
writeSegmentIndex = j + 1
|
writeSegmentIndex = last + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
segment, err := CreateSegment(w.dir, writeSegmentIndex)
|
segment, err := CreateSegment(w.dir, writeSegmentIndex)
|
||||||
|
|
Loading…
Reference in New Issue