Skip to content

Commit 7326b3f

Browse files
committed
fix race in test
1 parent 6b55856 commit 7326b3f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

writers/streamingbatchwriter/streamingbatchwriter_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ func (c *testStreamingBatchClient) WriteTable(ctx context.Context, msgs <-chan *
7979
key := ""
8080
for m := range msgs {
8181
key = c.handleTypeMessage(ctx, messageTypeInsert, m, key)
82+
83+
c.mutex.Lock()
8284
c.writeCounter[key]++
85+
currentCount := c.writeCounter[key]
86+
c.mutex.Unlock()
8387

84-
if c.writeErr != nil && c.writeCounter[key] > c.writeErrAfter {
88+
if c.writeErr != nil && currentCount > c.writeErrAfter {
8589
return c.writeErr // leave msgs open
8690
}
8791
}

0 commit comments

Comments
 (0)