From 36e1d650a1351425dd2b95f2720f6ee0f4f55e91 Mon Sep 17 00:00:00 2001 From: Clay Douglass Date: Wed, 8 May 2019 14:45:07 -0500 Subject: [PATCH] tweeked the flag handling for readytosave --- engine/factomd_test.go | 4 ++-- state/stateConsensus.go | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/engine/factomd_test.go b/engine/factomd_test.go index 3d43c7a400..f56baf6ce5 100644 --- a/engine/factomd_test.go +++ b/engine/factomd_test.go @@ -132,9 +132,9 @@ func TestLoad(t *testing.T) { RanSimTest = true // use a tree so the messages get reordered - state0 := SetupSim("LLF", map[string]string{"--debuglog": ""}, 15, 0, 0, t) + state0 := SetupSim("LFF", map[string]string{"--debuglog": ""}, 15, 0, 0, t) - RunCmd("2") // select 2 + // RunCmd("2") // select 2 RunCmd("R30") // Feed load WaitBlocks(state0, 10) RunCmd("R0") // Stop load diff --git a/state/stateConsensus.go b/state/stateConsensus.go index bced3551c0..6d8e8b6406 100644 --- a/state/stateConsensus.go +++ b/state/stateConsensus.go @@ -747,8 +747,17 @@ func (s *State) MoveStateToHeight(dbheight uint32, newMinute int) { if s.Leader && !s.LeaderPL.DBSigAlreadySent { s.SendDBSig(s.LLeaderHeight, s.LeaderVMIndex) // MoveStateToHeight() } + s.DBStates.UpdateState() // call to get the state signed now that the DBSigs have processed } else if s.CurrentMinute != newMinute { // And minute + if newMinute == 1 { + dbstate := s.GetDBState(dbheight - 1) + if dbstate != nil && !dbstate.Saved { + s.LogPrintf("dbstateprocess", "Set ReadyToSave %d", dbstate.DirectoryBlock.GetHeader().GetDBHeight()) + dbstate.ReadyToSave = true + } + s.DBStates.UpdateState() // call to get the state signed now that the DBSigs have processed + } s.CurrentMinute = newMinute // Update just the minute s.Leader, s.LeaderVMIndex = s.LeaderPL.GetVirtualServers(newMinute, s.IdentityChainID) // MoveStateToHeight minute // We are between blocks make sure we are setup to sync @@ -761,9 +770,6 @@ func (s *State) MoveStateToHeight(dbheight uint32, newMinute int) { s.LeaderPL.SortAuditServers() s.LeaderPL.SortFedServers() - if newMinute == 1 { - defer s.DBStates.UpdateState() - } } { // debug @@ -2015,16 +2021,12 @@ func (s *State) ProcessEOM(dbheight uint32, msg interfaces.IMsg) bool { switch { case s.CurrentMinute < 10: if s.CurrentMinute == 1 { - dbstate := s.GetDBState(dbheight - 1) // Panic had arose when leaders would reboot and the follower was on a future minute if dbstate == nil { // We recognize that this will leave us "Done" without finishing the process. But // a Follower can heal themselves by asking for a block, and overwriting this block. return false } - if !dbstate.Saved { - dbstate.ReadyToSave = true - } } LeaderPL := s.ProcessLists.Get(s.LLeaderHeight) if s.LeaderPL != LeaderPL {