Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still return continuous WAL entries when running into ErrSliceOutOfRange #19095

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions server/storage/wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion tests/robustness/report/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading