Skip to content

Commit 64196a7

Browse files
committed
util/log: skip malformed log entries while reading from file
Previously, readAllEntriesFromFile was returning an error if the log file contains the malformed log entry. The malformed log entry primarily could be the unexpected panic log. This would result in failure in fetching the logs from file. This was inadequate because single log line can cause failure in reading rest of the logs which are with valid format. To address this, this patch skips the malformed log entries during decode and only valid log lines are returned. Fixes: #149866 Informs: #151493 Release note: None
1 parent c75f1e2 commit 64196a7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/util/log/file_api.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@ func readAllEntriesFromFile(
429429
if err == io.EOF {
430430
break
431431
}
432+
433+
// skip the malformed log entry. This is primarily observed in the
434+
// panic which is unstructured.
435+
// See: https://github.com/cockroachdb/cockroach/issues/151493
436+
if errors.Is(err, ErrMalformedLogEntry) {
437+
continue
438+
}
432439
return nil, false, err
433440
}
434441
var match bool

0 commit comments

Comments
 (0)