mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
Chore: Log segment number when segment read failed (#7687)
* Chore: Log segment number when segment read failed To manually fix the WAL files, it is good to know where the corrupt happened so we should log the segment number when the read failed. Related Issue #7506 Signed-off-by: gaston.qiu <gaston.qiu@umbocv.com>
This commit is contained in:
parent
d19fc71903
commit
5a7d398d19
@ -391,7 +391,7 @@ func (w *Watcher) watch(segmentNum int, tail bool) error {
|
|||||||
|
|
||||||
// Ignore errors reading to end of segment whilst replaying the WAL.
|
// Ignore errors reading to end of segment whilst replaying the WAL.
|
||||||
if !tail {
|
if !tail {
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && errors.Cause(err) != io.EOF {
|
||||||
level.Warn(w.logger).Log("msg", "Ignoring error reading to end of segment, may have dropped data", "err", err)
|
level.Warn(w.logger).Log("msg", "Ignoring error reading to end of segment, may have dropped data", "err", err)
|
||||||
} else if reader.Offset() != size {
|
} else if reader.Offset() != size {
|
||||||
level.Warn(w.logger).Log("msg", "Expected to have read whole segment, may have dropped data", "segment", segmentNum, "read", reader.Offset(), "size", size)
|
level.Warn(w.logger).Log("msg", "Expected to have read whole segment, may have dropped data", "segment", segmentNum, "read", reader.Offset(), "size", size)
|
||||||
@ -400,7 +400,7 @@ func (w *Watcher) watch(segmentNum int, tail bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, when we are tailing, non-EOFs are fatal.
|
// Otherwise, when we are tailing, non-EOFs are fatal.
|
||||||
if err != io.EOF {
|
if errors.Cause(err) != io.EOF {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ func (w *Watcher) watch(segmentNum int, tail bool) error {
|
|||||||
|
|
||||||
// Ignore all errors reading to end of segment whilst replaying the WAL.
|
// Ignore all errors reading to end of segment whilst replaying the WAL.
|
||||||
if !tail {
|
if !tail {
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && errors.Cause(err) != io.EOF {
|
||||||
level.Warn(w.logger).Log("msg", "Ignoring error reading to end of segment, may have dropped data", "segment", segmentNum, "err", err)
|
level.Warn(w.logger).Log("msg", "Ignoring error reading to end of segment, may have dropped data", "segment", segmentNum, "err", err)
|
||||||
} else if reader.Offset() != size {
|
} else if reader.Offset() != size {
|
||||||
level.Warn(w.logger).Log("msg", "Expected to have read whole segment, may have dropped data", "segment", segmentNum, "read", reader.Offset(), "size", size)
|
level.Warn(w.logger).Log("msg", "Expected to have read whole segment, may have dropped data", "segment", segmentNum, "read", reader.Offset(), "size", size)
|
||||||
@ -420,7 +420,7 @@ func (w *Watcher) watch(segmentNum int, tail bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, when we are tailing, non-EOFs are fatal.
|
// Otherwise, when we are tailing, non-EOFs are fatal.
|
||||||
if err != io.EOF {
|
if errors.Cause(err) != io.EOF {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,7 +516,7 @@ func (w *Watcher) readSegment(r *LiveReader, segmentNum int, tail bool) error {
|
|||||||
return errors.New("unknown TSDB record type")
|
return errors.New("unknown TSDB record type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.Err()
|
return errors.Wrapf(r.Err(), "segment %d: %v", segmentNum, r.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Watcher) SetStartTime(t time.Time) {
|
func (w *Watcher) SetStartTime(t time.Time) {
|
||||||
@ -565,7 +565,7 @@ func (w *Watcher) readCheckpoint(checkpointDir string) error {
|
|||||||
defer sr.Close()
|
defer sr.Close()
|
||||||
|
|
||||||
r := NewLiveReader(w.logger, w.readerMetrics, sr)
|
r := NewLiveReader(w.logger, w.readerMetrics, sr)
|
||||||
if err := w.readSegment(r, index, false); err != io.EOF && err != nil {
|
if err := w.readSegment(r, index, false); errors.Cause(err) != io.EOF && err != nil {
|
||||||
return errors.Wrap(err, "readSegment")
|
return errors.Wrap(err, "readSegment")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user