From d1848b96fc5943f68cfecb1e2f1c9e02734edf06 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Mon, 11 Feb 2019 17:33:20 +0000 Subject: [PATCH] Fix possible assertion failure in IndicesQueryCache.close (#38731) The assertion that the stats2 map is empty in IndicesQueryCache.close has been observed to fail very occasionally in internal cluster tests. The likely cause is a cross-thread visibility problem for a count variable. This change makes that count volatile. Relates #37117 Backport of #38714 --- .../main/java/org/elasticsearch/indices/IndicesQueryCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesQueryCache.java b/server/src/main/java/org/elasticsearch/indices/IndicesQueryCache.java index 1dfbc3af42b..814288dbe58 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesQueryCache.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesQueryCache.java @@ -206,7 +206,7 @@ public class IndicesQueryCache implements QueryCache, Closeable { } private static class StatsAndCount { - int count; + volatile int count; final Stats stats; StatsAndCount(Stats stats) {