Skip to content

Commit

Permalink
wal: repair decoder needs to update its crc
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Mar 30, 2015
1 parent 0b9a318 commit 3e9a033
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wal/repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ func Repair(dirpath string) bool {
switch err {
case nil:
n += 8 + rec.Size()
// update crc of the decoder when necessary
switch rec.Type {
case crcType:
crc := decoder.crc.Sum32()
// current crc of decoder must match the crc of the record.
// do no need to match 0 crc, since the decoder is a new one at this case.
if crc != 0 && rec.Validate(crc) != nil {
return false
}
decoder.updateCRC(rec.Crc)
}
continue
case io.EOF:
return true
Expand Down Expand Up @@ -74,6 +85,9 @@ func Repair(dirpath string) bool {
return false
}
return true
default:
log.Printf("wal: could not repair error (%v)", err)
return false
}
}
}
Expand Down

0 comments on commit 3e9a033

Please sign in to comment.