Skip to content

Commit dc444ce

Browse files
Fix Race in Closing IndicesService.CacheCleaner (#42016) (#42052)
* 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 906999f commit dc444ce

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
@@ -65,6 +65,7 @@
6565
import org.elasticsearch.common.util.BigArrays;
6666
import org.elasticsearch.common.util.concurrent.AbstractRefCounted;
6767
import org.elasticsearch.common.util.concurrent.EsExecutors;
68+
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
6869
import org.elasticsearch.common.util.iterable.Iterables;
6970
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
7071
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@@ -1225,7 +1226,13 @@ public void run() {
12251226
}
12261227
// Reschedule itself to run again if not closed
12271228
if (closed.get() == false) {
1228-
threadPool.schedule(this, interval, ThreadPool.Names.SAME);
1229+
try {
1230+
threadPool.schedule(this, interval, ThreadPool.Names.SAME);
1231+
} catch (EsRejectedExecutionException e) {
1232+
if (closed.get() == false) {
1233+
throw e;
1234+
}
1235+
}
12291236
}
12301237
}
12311238

0 commit comments

Comments
 (0)