}
break;
+ case kBadHeader:
+ if (wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency) {
+ // in clean shutdown we don't expect any error in the log files
+ ReportCorruption(buffer_.size(), "truncated header");
+ }
+ // fall-thru
+
case kEof:
if (in_fragmented_record) {
if (wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency) {
// end of the file, which can be caused by the writer crashing in the
// middle of writing the header. Unless explicitly requested we don't
// considering this an error, just report EOF.
- if (buffer_.size() &&
- wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency) {
- // in clean shutdown we don't expect any error in the log files
- ReportCorruption(buffer_.size(), "truncated header");
- }
+ if (buffer_.size()) {
+ buffer_.clear();
+ return kBadHeader;
+ }
buffer_.clear();
return kEof;
}
// * The record has an invalid CRC (ReadPhysicalRecord reports a drop)
// * The record is a 0-length record (No drop is reported)
// * The record is below constructor's initial_offset (No drop is reported)
- kBadRecord = kMaxRecordType + 2
+ kBadRecord = kMaxRecordType + 2,
+ // Returned when we fail to read a valid header.
+ kBadHeader = kMaxRecordType + 3,
};
// Skips all blocks that are completely before "initial_offset_".