solr
solr copied to clipboard
Catch cancellation exceptions - Fix TestTolerantSearch
Currently, TestTolerantSearch.testAllShardsFail fails with the following:
com.carrotsearch.randomizedtesting.UncaughtExceptionError: Captured an uncaught exception in thread: Thread[id=312, name=httpShardExecutor-171-thread-3, state=RUNNABLE, group=TGRP-TestTolerantSearch]
at __randomizedtesting.SeedInfo.seed([E82DD9D830F6392B:772D812CE6F65EDC]:0)
Caused by: java.util.concurrent.CancellationException
at __randomizedtesting.SeedInfo.seed([E82DD9D830F6392B]:0)
at java.base/java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2510)
at org.apache.solr.client.solrj.impl.LBHttp2SolrClient.lambda$requestAsync$0(LBHttp2SolrClient.java:190)
at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:990)
at java.base/java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:974)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2512)
at org.apache.solr.handler.component.HttpShardHandler.cancelAll(HttpShardHandler.java:361)
I think ultimately, somewhere in the loop the cancellations are not being caught. And I think we can actually catch it in 2 places, ultimately in the ExecutorUtil that does this error catching logic (to log it out), but also in the place I think the error is actually stemming from (since we will likely want to cancel the future if it isn't cancelled already).