From 3c18d841fa44093d6a501ed55a11c25145944e0a Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Tue, 11 Oct 2016 12:51:48 -0400 Subject: [PATCH] replay: larger read buffer --- consensus/common_test.go | 11 +++++++++++ consensus/replay.go | 10 ++++++++-- consensus/replay_test.go | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/consensus/common_test.go b/consensus/common_test.go index 12eeeb565..7cb3418cd 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -18,6 +18,7 @@ import ( tmsp "github.com/tendermint/tmsp/types" "github.com/tendermint/tmsp/example/counter" + "github.com/tendermint/tmsp/example/dummy" ) var config cfg.Config // NOTE: must be reset for each _test.go file @@ -320,6 +321,16 @@ func fixedConsensusState() *ConsensusState { return cs } +func fixedConsensusStateDummy() *ConsensusState { + stateDB := dbm.NewMemDB() + state := sm.MakeGenesisStateFromFile(stateDB, config.GetString("genesis_file")) + privValidatorFile := config.GetString("priv_validator_file") + privValidator := types.LoadOrGenPrivValidator(privValidatorFile) + privValidator.Reset() + cs := newConsensusState(state, privValidator, dummy.NewDummyApplication()) + return cs +} + func newConsensusState(state *sm.State, pv *types.PrivValidator, app tmsp.Application) *ConsensusState { // Get BlockStore blockDB := dbm.NewMemDB() diff --git a/consensus/replay.go b/consensus/replay.go index 9bb0fb055..c77d0558c 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -116,20 +116,26 @@ func (cs *ConsensusState) catchupReplay(height int) error { // now we can replay the latest nLines on consensus state // note we can't use scan because we've already been reading from the file - reader := bufio.NewReader(cs.wal.fp) + // XXX: if a msg is too big we need to find out why or increase this for that case ... + maxMsgSize := 1000000 + reader := bufio.NewReaderSize(cs.wal.fp, maxMsgSize) for i := 0; i < nLines; i++ { msgBytes, err := reader.ReadBytes('\n') if err == io.EOF { + log.Warn("Replay: EOF", "bytes", string(msgBytes)) break } else if err != nil { return err } else if len(msgBytes) == 0 { + log.Warn("Replay: msg bytes is 0") continue } else if len(msgBytes) == 1 && msgBytes[0] == '\n' { + log.Warn("Replay: new line") continue } // the first msg is the NewHeight event (if we're not at the beginning), so we can ignore it if !beginning && i == 1 { + log.Warn("Replay: not beginning and 1") continue } @@ -140,7 +146,7 @@ func (cs *ConsensusState) catchupReplay(height int) error { return err } } - log.Notice("Done catchup replay") + log.Notice("Replay: Done") return nil } diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 01e48c7f5..9fed2e8e3 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -114,7 +114,7 @@ func setupReplayTest(thisCase *testCase, nLines int, crashAfter bool) (*Consensu // we write those lines up to (not including) one with the signature fileName := writeWAL(strings.Join(split[:nLines], "\n") + "\n") - cs := fixedConsensusState() + cs := fixedConsensusStateDummy() // set the last step according to when we crashed vs the wal cs.privValidator.LastHeight = 1 // first block