|
|
@ -163,7 +163,7 @@ func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions) |
|
|
|
// NOTE: starting from the last file in the group because we're usually
|
|
|
|
// searching for the last height. See replay.go
|
|
|
|
min, max := wal.group.MinIndex(), wal.group.MaxIndex() |
|
|
|
wal.Logger.Debug("Searching for height", "height", height, "min", min, "max", max) |
|
|
|
wal.Logger.Info("Searching for height", "height", height, "min", min, "max", max) |
|
|
|
for index := max; index >= min; index-- { |
|
|
|
gr, err = wal.group.NewReader(index) |
|
|
|
if err != nil { |
|
|
@ -183,7 +183,7 @@ func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions) |
|
|
|
break |
|
|
|
} |
|
|
|
if options.IgnoreDataCorruptionErrors && IsDataCorruptionError(err) { |
|
|
|
wal.Logger.Debug("Corrupted entry. Skipping...", "err", err) |
|
|
|
wal.Logger.Error("Corrupted entry. Skipping...", "err", err) |
|
|
|
// do nothing
|
|
|
|
continue |
|
|
|
} else if err != nil { |
|
|
@ -194,7 +194,7 @@ func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions) |
|
|
|
if m, ok := msg.Msg.(EndHeightMessage); ok { |
|
|
|
lastHeightFound = m.Height |
|
|
|
if m.Height == height { // found
|
|
|
|
wal.Logger.Debug("Found", "height", height, "index", index) |
|
|
|
wal.Logger.Info("Found", "height", height, "index", index) |
|
|
|
return gr, true, nil |
|
|
|
} |
|
|
|
} |
|
|
@ -281,25 +281,25 @@ func (dec *WALDecoder) Decode() (*TimedWALMessage, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("failed to read checksum: %v", err) |
|
|
|
return nil, DataCorruptionError{fmt.Errorf("failed to read checksum: %v", err)} |
|
|
|
} |
|
|
|
crc := binary.BigEndian.Uint32(b) |
|
|
|
|
|
|
|
b = make([]byte, 4) |
|
|
|
_, err = dec.rd.Read(b) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("failed to read length: %v", err) |
|
|
|
return nil, DataCorruptionError{fmt.Errorf("failed to read length: %v", err)} |
|
|
|
} |
|
|
|
length := binary.BigEndian.Uint32(b) |
|
|
|
|
|
|
|
if length > maxMsgSizeBytes { |
|
|
|
return nil, fmt.Errorf("length %d exceeded maximum possible value of %d bytes", length, maxMsgSizeBytes) |
|
|
|
return nil, DataCorruptionError{fmt.Errorf("length %d exceeded maximum possible value of %d bytes", length, maxMsgSizeBytes)} |
|
|
|
} |
|
|
|
|
|
|
|
data := make([]byte, length) |
|
|
|
_, err = dec.rd.Read(data) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("failed to read data: %v", err) |
|
|
|
return nil, DataCorruptionError{fmt.Errorf("failed to read data: %v", err)} |
|
|
|
} |
|
|
|
|
|
|
|
// check checksum before decoding data
|
|
|
|