From 72b21678c193fb932c425258784a2aa7e65c4df5 Mon Sep 17 00:00:00 2001 From: Andrew Prudhomme Date: Mon, 22 Apr 2024 15:45:38 -0700 Subject: [PATCH 1/2] Use direct executor for DrillSideways tasks --- .../nrtsearch/server/luceneserver/SearchHandler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java b/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java index a8b8d9666..d754c0ba0 100644 --- a/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java +++ b/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java @@ -16,6 +16,7 @@ package com.yelp.nrtsearch.server.luceneserver; import com.google.common.collect.Lists; +import com.google.common.util.concurrent.MoreExecutors; import com.google.protobuf.Struct; import com.google.protobuf.util.JsonFormat; import com.yelp.nrtsearch.server.grpc.DeadlineUtils; @@ -53,10 +54,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.*; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -77,6 +75,7 @@ import org.slf4j.LoggerFactory; public class SearchHandler implements Handler { + private static final ExecutorService DIRECT_EXECUTOR = MoreExecutors.newDirectExecutorService(); private static final Logger logger = LoggerFactory.getLogger(SearchHandler.class); private final ThreadPoolExecutor threadPoolExecutor; @@ -148,7 +147,7 @@ public SearchResponse handle(IndexState indexState, SearchRequest searchRequest) shardState, searchContext.getQueryFields(), grpcFacetResults, - threadPoolExecutor, + DIRECT_EXECUTOR, diagnostics); DrillSideways.ConcurrentDrillSidewaysResult concurrentDrillSidewaysResult; try { From 7795533011097c14d8cd8f7a3c853d25be6d1a7f Mon Sep 17 00:00:00 2001 From: Andrew Prudhomme Date: Mon, 22 Apr 2024 16:08:54 -0700 Subject: [PATCH 2/2] Add comment --- .../yelp/nrtsearch/server/luceneserver/SearchHandler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java b/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java index d754c0ba0..35d8d3f96 100644 --- a/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java +++ b/src/main/java/com/yelp/nrtsearch/server/luceneserver/SearchHandler.java @@ -136,6 +136,11 @@ public SearchResponse handle(IndexState indexState, SearchRequest searchRequest) DrillDownQuery ddq = (DrillDownQuery) searchContext.getQuery(); List grpcFacetResults = new ArrayList<>(); + // Run the drill sideways search on the direct executor to run subtasks in the + // current (grpc) thread. If we use the search thread pool for this, it can cause a + // deadlock trying to execute the dependent parallel search tasks. Since we do not + // currently add additional drill down definitions, there will only be one drill + // sideways task per query. DrillSideways drillS = new DrillSidewaysImpl( s.searcher,