From f9d00967444e4ca4c716dec171e71ae8c892f935 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 15 Apr 2017 02:02:33 -0400 Subject: [PATCH] support #HEIGHT based WAL --- consensus/replay.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/consensus/replay.go b/consensus/replay.go index 0adb333c7..f43c5ecad 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -115,12 +115,31 @@ func (cs *ConsensusState) catchupReplay(csHeight int) error { gr, found, err = cs.wal.group.Search("#ENDHEIGHT: ", makeHeightSearchFunc(csHeight-1)) if err == io.EOF { log.Warn("Replay: wal.group.Search returned EOF", "#ENDHEIGHT", csHeight-1) - return nil + // if we upgraded from 0.9 to 0.9.1, we may have #HEIGHT instead + // TODO (0.10.0): remove this + gr, found, err = cs.wal.group.Search("#HEIGHT: ", makeHeightSearchFunc(csHeight)) + if err == io.EOF { + log.Warn("Replay: wal.group.Search returned EOF", "#HEIGHT", csHeight) + return nil + } else if err != nil { + return err + } } else if err != nil { return err } if !found { - return errors.New(Fmt("Cannot replay height %d. WAL does not contain #ENDHEIGHT for %d.", csHeight, csHeight-1)) + // if we upgraded from 0.9 to 0.9.1, we may have #HEIGHT instead + // TODO (0.10.0): remove this + gr, found, err = cs.wal.group.Search("#HEIGHT: ", makeHeightSearchFunc(csHeight)) + if err == io.EOF { + log.Warn("Replay: wal.group.Search returned EOF", "#HEIGHT", csHeight) + return nil + } else if err != nil { + return err + } + + // TODO (0.10.0): uncomment + // return errors.New(Fmt("Cannot replay height %d. WAL does not contain #ENDHEIGHT for %d.", csHeight, csHeight-1)) } defer gr.Close()