Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,16 @@ public void testCancelFailedSearchWhenPartialResultDisallowed() throws Exception
// When the search request executes, block all shards except 1.
final List<SearchShardBlockingPlugin> searchShardBlockingPlugins = initSearchShardBlockingPlugin();
AtomicBoolean letOneShardProceed = new AtomicBoolean();
// Ensure we have at least one task waiting on the latch
CountDownLatch waitingTaskLatch = new CountDownLatch(1);
CountDownLatch shardTaskLatch = new CountDownLatch(1);
for (SearchShardBlockingPlugin plugin : searchShardBlockingPlugins) {
plugin.setRunOnNewReaderContext((ReaderContext c) -> {
if (letOneShardProceed.compareAndSet(false, true)) {
// Let one shard continue.
} else {
// Signal that we have a task waiting on the latch
waitingTaskLatch.countDown();
safeAwait(shardTaskLatch); // Block the other shards.
}
});
Expand All @@ -280,6 +284,9 @@ public void testCancelFailedSearchWhenPartialResultDisallowed() throws Exception
plugin.disableBlock();
plugin.setBeforeExecution(() -> {
if (oneThreadWillError.compareAndSet(false, true)) {
// wait for some task to get to the latch
safeAwait(waitingTaskLatch);
// then throw the exception
throw new IllegalStateException("This will cancel the ContextIndexSearcher.search task");
}
});
Expand Down