Skip to content

Commit ef79dd7

Browse files
author
Marko Vukolic
committed
fix sbft checkpoint backlog bug
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 <[email protected]>
1 parent fe6be01 commit ef79dd7

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

orderer/sbft/simplebft/backlog.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const maxBacklogSeq = 4
2222
const msgPerSeq = 3 // (pre)prepare, commit, checkpoint
2323

2424
func (s *SBFT) testBacklogMessage(m *Msg, src uint64) bool {
25-
record := func(seq *SeqView) bool {
25+
test := func(seq *SeqView) bool {
2626
if !s.activeView {
2727
return true
2828
}
@@ -33,14 +33,13 @@ func (s *SBFT) testBacklogMessage(m *Msg, src uint64) bool {
3333
}
3434

3535
if pp := m.GetPreprepare(); pp != nil {
36-
return record(pp.Seq) && !s.cur.checkpointDone
36+
return test(pp.Seq) && !s.cur.checkpointDone
3737
} else if p := m.GetPrepare(); p != nil {
38-
return record(p.Seq)
38+
return test(p.Seq)
3939
} else if c := m.GetCommit(); c != nil {
40-
return record(c.Seq)
41-
} else if cs := m.GetCheckpoint(); cs != nil {
42-
c := &Checkpoint{}
43-
return record(&SeqView{Seq: c.Seq})
40+
return test(c.Seq)
41+
} else if chk := m.GetCheckpoint(); chk != nil {
42+
return test(&SeqView{Seq: chk.Seq})
4443
}
4544
return false
4645
}
@@ -53,6 +52,7 @@ func (s *SBFT) recordBacklogMsg(m *Msg, src uint64) {
5352
s.replicaState[src].backLog = append(s.replicaState[src].backLog, m)
5453

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

6565
func (s *SBFT) processBacklog() {
6666
processed := true
67-
notReady := uint64(0)
6867

6968
for processed {
7069
processed = false
@@ -75,7 +74,6 @@ func (s *SBFT) processBacklog() {
7574
for len(state.backLog) > 0 {
7675
m, rest := state.backLog[0], state.backLog[1:]
7776
if s.testBacklogMessage(m, src) {
78-
notReady++
7977
break
8078
}
8179
state.backLog = rest

0 commit comments

Comments
 (0)