Skip to content

Commit d8417dc

Browse files
Fix Race in Closing IndicesService.CacheCleaner (#42016)
* When close becomes true while the management pool is shut down, we run into an unhandled `EsRejectedExecutionException` that fails tests * Found this while trying to reproduce #32506 * Running the IndexStatsIT in a loop is a way of reproducing this
1 parent 9f39879 commit d8417dc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/src/main/java/org/elasticsearch/indices/IndicesService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import org.elasticsearch.common.util.Maps;
6767
import org.elasticsearch.common.util.concurrent.AbstractRefCounted;
6868
import org.elasticsearch.common.util.concurrent.EsExecutors;
69+
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
6970
import org.elasticsearch.common.util.iterable.Iterables;
7071
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
7172
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@@ -1219,7 +1220,13 @@ public void run() {
12191220
}
12201221
// Reschedule itself to run again if not closed
12211222
if (closed.get() == false) {
1222-
threadPool.schedule(this, interval, ThreadPool.Names.SAME);
1223+
try {
1224+
threadPool.schedule(this, interval, ThreadPool.Names.SAME);
1225+
} catch (EsRejectedExecutionException e) {
1226+
if (closed.get() == false) {
1227+
throw e;
1228+
}
1229+
}
12231230
}
12241231
}
12251232

0 commit comments

Comments
 (0)