|
@@ -203,7 +203,7 @@ func openAtIndex(dirpath string, snap walpb.Snapshot, all bool) (*WAL, error) {
|
|
|
// ReadAll reads out all records of the current WAL.
|
|
// ReadAll reads out all records of the current WAL.
|
|
|
// If it cannot read out the expected snap, it will return ErrSnapshotNotFound.
|
|
// If it cannot read out the expected snap, it will return ErrSnapshotNotFound.
|
|
|
// If loaded snap doesn't match with the expected one, it will return
|
|
// If loaded snap doesn't match with the expected one, it will return
|
|
|
-// ErrSnapshotMismatch.
|
|
|
|
|
|
|
+// all the records and error ErrSnapshotMismatch.
|
|
|
// TODO: detect not-last-snap error.
|
|
// TODO: detect not-last-snap error.
|
|
|
// TODO: maybe loose the checking of match.
|
|
// TODO: maybe loose the checking of match.
|
|
|
// After ReadAll, the WAL will be ready for appending new records.
|
|
// After ReadAll, the WAL will be ready for appending new records.
|
|
@@ -256,9 +256,9 @@ func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb.
|
|
|
state.Reset()
|
|
state.Reset()
|
|
|
return nil, state, nil, err
|
|
return nil, state, nil, err
|
|
|
}
|
|
}
|
|
|
|
|
+ err = nil
|
|
|
if !match {
|
|
if !match {
|
|
|
- state.Reset()
|
|
|
|
|
- return nil, state, nil, ErrSnapshotNotFound
|
|
|
|
|
|
|
+ err = ErrSnapshotNotFound
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// close decoder, disable reading
|
|
// close decoder, disable reading
|
|
@@ -269,7 +269,7 @@ func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb.
|
|
|
// create encoder (chain crc with the decoder), enable appending
|
|
// create encoder (chain crc with the decoder), enable appending
|
|
|
w.encoder = newEncoder(w.f, w.decoder.lastCRC())
|
|
w.encoder = newEncoder(w.f, w.decoder.lastCRC())
|
|
|
w.decoder = nil
|
|
w.decoder = nil
|
|
|
- return metadata, state, ents, nil
|
|
|
|
|
|
|
+ return metadata, state, ents, err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Cut closes current file written and creates a new one ready to append.
|
|
// Cut closes current file written and creates a new one ready to append.
|