From 0545a5a1c3bd90fda386dff709c54418879978ea Mon Sep 17 00:00:00 2001 From: mazing80 Date: Thu, 17 Mar 2016 02:04:12 +0900 Subject: [PATCH] Fix datarace issue for PendingDocuments function --- lib/corebulk.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/corebulk.go b/lib/corebulk.go index 35a194fb..131b1026 100644 --- a/lib/corebulk.go +++ b/lib/corebulk.go @@ -162,7 +162,10 @@ func (b *BulkIndexer) Stop() { } func (b *BulkIndexer) PendingDocuments() int { - return b.docCt + b.mu.Lock() + docCt := b.docCt + b.mu.Unlock() + return docCt } // Flush all current documents to ElasticSearch