mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 14:27:27 -08:00
WAL watcher: improve comments
Clarify in the first comment that it is `watch()` that waits, and reduce verbiage. The second comment was slightly contradictory to the first and otherwise didn't seem to add much, since `currentSegment` was incremented just a few lines later. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
a975a83079
commit
6ed56c9f04
|
@ -290,8 +290,8 @@ func (w *Watcher) Run() error {
|
||||||
for !isClosed(w.quit) {
|
for !isClosed(w.quit) {
|
||||||
w.currentSegmentMetric.Set(float64(currentSegment))
|
w.currentSegmentMetric.Set(float64(currentSegment))
|
||||||
|
|
||||||
// Reset the value of lastSegment each iteration, this is to avoid having to wait too long for
|
// Re-check on each iteration in case a new segment was added,
|
||||||
// between reads if we're reading a segment that is not the most recent segment after startup.
|
// because watch() will wait for notifications on the last segment.
|
||||||
_, lastSegment, err := w.firstAndLast()
|
_, lastSegment, err := w.firstAndLast()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("wal.Segments: %w", err)
|
return fmt.Errorf("wal.Segments: %w", err)
|
||||||
|
@ -299,8 +299,6 @@ func (w *Watcher) Run() error {
|
||||||
tail := currentSegment >= lastSegment
|
tail := currentSegment >= lastSegment
|
||||||
|
|
||||||
level.Debug(w.logger).Log("msg", "Processing segment", "currentSegment", currentSegment, "lastSegment", lastSegment)
|
level.Debug(w.logger).Log("msg", "Processing segment", "currentSegment", currentSegment, "lastSegment", lastSegment)
|
||||||
// On start, after reading the existing WAL for series records, we have a pointer to what is the latest segment.
|
|
||||||
// On subsequent calls to this function, currentSegment will have been incremented and we should open that segment.
|
|
||||||
if err := w.watch(currentSegment, tail); err != nil && !errors.Is(err, ErrIgnorable) {
|
if err := w.watch(currentSegment, tail); err != nil && !errors.Is(err, ErrIgnorable) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue