From d176afa7ecc667dafd2bc11d65e62531f0c6063d Mon Sep 17 00:00:00 2001 From: Harlow Ward Date: Mon, 8 Apr 2019 19:34:47 -0700 Subject: [PATCH] protect counter race condition --- consumer_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/consumer_test.go b/consumer_test.go index c9e6c62..f1edcd9 100644 --- a/consumer_test.go +++ b/consumer_test.go @@ -321,8 +321,12 @@ func (fc *fakeCheckpoint) Get(streamName, shardID string) (string, error) { // implementation of counter type fakeCounter struct { counter int64 + mu sync.Mutex } func (fc *fakeCounter) Add(streamName string, count int64) { + fc.mu.Lock() + defer fc.mu.Unlock() + fc.counter += count }