From f089c2f15893ed625278f1165a254fd5f37c844d Mon Sep 17 00:00:00 2001 From: Behrooz Shafiee Date: Mon, 1 Apr 2019 12:44:06 -0400 Subject: [PATCH] this causes race condition when multiple IndexWriter Flush is called, the fix simply moves global unprotected vars to local func scope --- index/write.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index/write.go b/index/write.go index 15802a47f8..0ced07708e 100644 --- a/index/write.go +++ b/index/write.go @@ -599,10 +599,11 @@ func validUTF8(c1, c2 uint32) bool { // 24 bits to sort. Run two rounds of 12-bit radix sort. const sortK = 12 -var sortTmp []postEntry -var sortN [1 << sortK]int func sortPost(post []postEntry) { + var sortTmp []postEntry + var sortN [1 << sortK]int + if len(post) > len(sortTmp) { sortTmp = make([]postEntry, len(post)) }