Skip to content

Commit

Permalink
Make SBFT application's enqueue operations non-blocking
Browse files Browse the repository at this point in the history
Backend has a main consumer process (run()) handling
the content of its queue (called 'queue', a channel).
This goroutine has to be only a consumer but as it
executes messages from the queue, sometimes, it has
to also insert items acting as a producer. In this
case, blocking enqueue operations may block the
whole replica (application). One example for this
phenomenon is an enqueued message of type Receive.
This calls SBFT's Receive which may call function
recordBacklogMsg which may then call System's
Reconnect. This is implemented by Backend and tries
to enqueue a Connection message (enqueueConnection)
blocking the replica.

Change-Id: I1dd2a900570a1305ea17d20bfcd8cba81b437d24
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
  • Loading branch information
gaborh-da committed Dec 1, 2016
1 parent 9bd4e85 commit 70811b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions orderer/sbft/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,15 @@ func (c *Backend) connectWorker(peer *PeerInfo) {
}

func (b *Backend) enqueueConnection(peerid uint64) {
b.queue <- &connectionEvent{peerid: peerid}
go func() {
b.queue <- &connectionEvent{peerid: peerid}
}()
}

func (b *Backend) enqueueRequest(request []byte) {
b.queue <- &requestEvent{req: request}
go func() {
b.queue <- &requestEvent{req: request}
}()
}

func (b *Backend) enqueueForReceive(msg *s.Msg, src uint64) {
Expand Down

0 comments on commit 70811b2

Please sign in to comment.