"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "server/wal/wal.go" between
etcd-3.5.6.tar.gz and etcd-3.5.7.tar.gz

About: etcd is a distributed reliable key-value store for the most critical data of a distributed system (written in "Go").

wal.go  (etcd-3.5.6):wal.go  (etcd-3.5.7)
skipping to change at line 503 skipping to change at line 503
state.Reset() state.Reset()
return nil, state, nil, fmt.Errorf("unexpected block type %d", rec.Type) return nil, state, nil, fmt.Errorf("unexpected block type %d", rec.Type)
} }
} }
switch w.tail() { switch w.tail() {
case nil: case nil:
// We do not have to read out all entries in read mode. // We do not have to read out all entries in read mode.
// The last record maybe a partial written one, so // The last record maybe a partial written one, so
// ErrunexpectedEOF might be returned. // ErrunexpectedEOF might be returned.
if err != io.EOF && err != io.ErrUnexpectedEOF { if !errors.Is(err, io.EOF) && !errors.Is(err, io.ErrUnexpectedEOF ) {
state.Reset() state.Reset()
return nil, state, nil, err return nil, state, nil, err
} }
default: default:
// We must read all of the entries if WAL is opened in write mode // We must read all the entries if WAL is opened in write mode.
. if !errors.Is(err, io.EOF) {
if err != io.EOF {
state.Reset() state.Reset()
return nil, state, nil, err return nil, state, nil, err
} }
// decodeRecord() will return io.EOF if it detects a zero record, // decodeRecord() will return io.EOF if it detects a zero record,
// but this zero record may be followed by non-zero records from // but this zero record may be followed by non-zero records from
// a torn write. Overwriting some of these non-zero records, but // a torn write. Overwriting some of these non-zero records, but
// not all, will cause CRC errors on WAL open. Since the records // not all, will cause CRC errors on WAL open. Since the records
// were never fully synced to disk in the first place, it's safe // were never fully synced to disk in the first place, it's safe
// to zero them out to avoid any CRC errors from new writes. // to zero them out to avoid any CRC errors from new writes.
if _, err = w.tail().Seek(w.decoder.lastOffset(), io.SeekStart); err != nil { if _, err = w.tail().Seek(w.decoder.lastOffset(), io.SeekStart); err != nil {
skipping to change at line 601 skipping to change at line 601
// current crc of decoder must match the crc of the recor d. // current crc of decoder must match the crc of the recor d.
// do no need to match 0 crc, since the decoder is a new one at this case. // do no need to match 0 crc, since the decoder is a new one at this case.
if crc != 0 && rec.Validate(crc) != nil { if crc != 0 && rec.Validate(crc) != nil {
return nil, ErrCRCMismatch return nil, ErrCRCMismatch
} }
decoder.updateCRC(rec.Crc) decoder.updateCRC(rec.Crc)
} }
} }
// We do not have to read out all the WAL entries // We do not have to read out all the WAL entries
// as the decoder is opened in read mode. // as the decoder is opened in read mode.
if err != io.EOF && err != io.ErrUnexpectedEOF { if !errors.Is(err, io.EOF) && !errors.Is(err, io.ErrUnexpectedEOF) {
return nil, err return nil, err
} }
// filter out any snaps that are newer than the committed hardstate // filter out any snaps that are newer than the committed hardstate
n := 0 n := 0
for _, s := range snaps { for _, s := range snaps {
if s.Index <= state.Commit { if s.Index <= state.Commit {
snaps[n] = s snaps[n] = s
n++ n++
} }
skipping to change at line 691 skipping to change at line 691
case entryType: case entryType:
case stateType: case stateType:
pbutil.MustUnmarshal(&state, rec.Data) pbutil.MustUnmarshal(&state, rec.Data)
default: default:
return nil, fmt.Errorf("unexpected block type %d", rec.Ty pe) return nil, fmt.Errorf("unexpected block type %d", rec.Ty pe)
} }
} }
// We do not have to read out all the WAL entries // We do not have to read out all the WAL entries
// as the decoder is opened in read mode. // as the decoder is opened in read mode.
if err != io.EOF && err != io.ErrUnexpectedEOF { if !errors.Is(err, io.EOF) && !errors.Is(err, io.ErrUnexpectedEOF) {
return nil, err return nil, err
} }
if !match { if !match {
return nil, ErrSnapshotNotFound return nil, ErrSnapshotNotFound
} }
return &state, nil return &state, nil
} }
 End of changes. 4 change blocks. 
6 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)