diff --git a/server/storage/wal/wal.go b/server/storage/wal/wal.go index b364cab63e8..f3d7bc5f4d4 100644 --- a/server/storage/wal/wal.go +++ b/server/storage/wal/wal.go @@ -487,8 +487,10 @@ func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb. // prevent "panic: runtime error: slice bounds out of range [:13038096702221461992] with capacity 0" offset := e.Index - w.start.Index - 1 if offset > uint64(len(ents)) { - // return error before append call causes runtime panic - return nil, state, nil, fmt.Errorf("%w, snapshot[Index: %d, Term: %d], current entry[Index: %d, Term: %d], len(ents): %d", + // return error before append call causes runtime panic. + // We still return the continuous WAL entries that have already been read. + // Refer to https://github.com/etcd-io/etcd/pull/19038#issuecomment-2557414292. + return nil, state, ents, fmt.Errorf("%w, snapshot[Index: %d, Term: %d], current entry[Index: %d, Term: %d], len(ents): %d", ErrSliceOutOfRange, w.start.Index, w.start.Term, e.Index, e.Term, len(ents)) } // The line below is potentially overriding some 'uncommitted' entries. diff --git a/tests/robustness/report/wal.go b/tests/robustness/report/wal.go index 5efa8b9b23b..133ba9bb100 100644 --- a/tests/robustness/report/wal.go +++ b/tests/robustness/report/wal.go @@ -114,7 +114,8 @@ func ReadWAL(lg *zap.Logger, dataDir string) (state raftpb.HardState, ents []raf _, state, ents, err = w.ReadAll() w.Close() if err != nil { - if errors.Is(err, wal.ErrSnapshotNotFound) { + if errors.Is(err, wal.ErrSnapshotNotFound) || errors.Is(err, wal.ErrSliceOutOfRange) { + lg.Info("Error occurred when reading WAL entries", zap.Error(err)) return state, ents, nil } // we can only repair ErrUnexpectedEOF and we never repair twice.