Skip to content

Commit

Permalink
fix sbft checkpoint backlog bug
Browse files Browse the repository at this point in the history
Checkpoints were never backloged in sbft. Variable naming was obscuring the
issue.

Piggybacked some refactoring and cleanup.

Change-Id: I8f08d8ea30a00cf9bc4f22b697d81d1790d6bc37
Signed-off-by: Marko Vukolic <mvu@zurich.ibm.com>
  • Loading branch information
Marko Vukolic committed Dec 8, 2016
1 parent fe6be01 commit ef79dd7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions orderer/sbft/simplebft/backlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const maxBacklogSeq = 4
const msgPerSeq = 3 // (pre)prepare, commit, checkpoint

func (s *SBFT) testBacklogMessage(m *Msg, src uint64) bool {
record := func(seq *SeqView) bool {
test := func(seq *SeqView) bool {
if !s.activeView {
return true
}
Expand All @@ -33,14 +33,13 @@ func (s *SBFT) testBacklogMessage(m *Msg, src uint64) bool {
}

if pp := m.GetPreprepare(); pp != nil {
return record(pp.Seq) && !s.cur.checkpointDone
return test(pp.Seq) && !s.cur.checkpointDone
} else if p := m.GetPrepare(); p != nil {
return record(p.Seq)
return test(p.Seq)
} else if c := m.GetCommit(); c != nil {
return record(c.Seq)
} else if cs := m.GetCheckpoint(); cs != nil {
c := &Checkpoint{}
return record(&SeqView{Seq: c.Seq})
return test(c.Seq)
} else if chk := m.GetCheckpoint(); chk != nil {
return test(&SeqView{Seq: chk.Seq})
}
return false
}
Expand All @@ -53,6 +52,7 @@ func (s *SBFT) recordBacklogMsg(m *Msg, src uint64) {
s.replicaState[src].backLog = append(s.replicaState[src].backLog, m)

if len(s.replicaState[src].backLog) > maxBacklogSeq*msgPerSeq {
log.Debugf("replica %d: backlog for %d full, discarding and reconnecting", s.id, src)
s.discardBacklog(src)
s.sys.Reconnect(src)
}
Expand All @@ -64,7 +64,6 @@ func (s *SBFT) discardBacklog(src uint64) {

func (s *SBFT) processBacklog() {
processed := true
notReady := uint64(0)

for processed {
processed = false
Expand All @@ -75,7 +74,6 @@ func (s *SBFT) processBacklog() {
for len(state.backLog) > 0 {
m, rest := state.backLog[0], state.backLog[1:]
if s.testBacklogMessage(m, src) {
notReady++
break
}
state.backLog = rest
Expand Down

0 comments on commit ef79dd7

Please sign in to comment.