From a329c406453c54ba21ba99f8e7d5f008b89343eb Mon Sep 17 00:00:00 2001 From: Xavi Ramirez Date: Tue, 18 Jul 2017 19:13:39 +0000 Subject: [PATCH] Fixed race condition --- batchconsumer/batcher/message_batcher.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/batchconsumer/batcher/message_batcher.go b/batchconsumer/batcher/message_batcher.go index 6aa9a64..4ac1d54 100644 --- a/batchconsumer/batcher/message_batcher.go +++ b/batchconsumer/batcher/message_batcher.go @@ -133,8 +133,10 @@ func (b *batcher) batchSize(batch [][]byte) int { func (b *batcher) flush(batch [][]byte) [][]byte { if len(batch) > 0 { + b.mux.Lock() b.sync.SendBatch(batch) b.smallestSeq = SequencePair{nil, 0} + b.mux.Unlock() } return [][]byte{} }