From 2ba3656ffd50213894eb189557069fd477f85652 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 17 Apr 2017 21:10:38 -0400 Subject: [PATCH] wal: gr.Close() --- consensus/replay.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/consensus/replay.go b/consensus/replay.go index 441b27018..0ebbb735f 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -104,12 +104,12 @@ func (cs *ConsensusState) catchupReplay(csHeight int) error { // NOTE: This is just a sanity check. As far as we know things work fine without it, // and Handshake could reuse ConsensusState if it weren't for this check (since we can crash after writing ENDHEIGHT). gr, found, err := cs.wal.group.Search("#ENDHEIGHT: ", makeHeightSearchFunc(csHeight)) - if found { - return errors.New(Fmt("WAL should not contain #ENDHEIGHT %d.", csHeight)) - } if gr != nil { gr.Close() } + if found { + return errors.New(Fmt("WAL should not contain #ENDHEIGHT %d.", csHeight)) + } // Search for last height marker gr, found, err = cs.wal.group.Search("#ENDHEIGHT: ", makeHeightSearchFunc(csHeight-1)) @@ -128,6 +128,7 @@ func (cs *ConsensusState) catchupReplay(csHeight int) error { return err } if !found { + gr.Close() // 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))