Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use direct executor for DrillSideways tasks #651

Merged
merged 2 commits into from
Apr 22, 2024
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 @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -77,6 +75,7 @@
import org.slf4j.LoggerFactory;

public class SearchHandler implements Handler<SearchRequest, SearchResponse> {
private static final ExecutorService DIRECT_EXECUTOR = MoreExecutors.newDirectExecutorService();

private static final Logger logger = LoggerFactory.getLogger(SearchHandler.class);
private final ThreadPoolExecutor threadPoolExecutor;
Expand Down Expand Up @@ -137,6 +136,11 @@ public SearchResponse handle(IndexState indexState, SearchRequest searchRequest)
DrillDownQuery ddq = (DrillDownQuery) searchContext.getQuery();

List<FacetResult> 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,
Expand All @@ -148,7 +152,7 @@ public SearchResponse handle(IndexState indexState, SearchRequest searchRequest)
shardState,
searchContext.getQueryFields(),
grpcFacetResults,
threadPoolExecutor,
DIRECT_EXECUTOR,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some comments here so that it's clear why we are using the direct executor?

diagnostics);
DrillSideways.ConcurrentDrillSidewaysResult<SearcherResult> concurrentDrillSidewaysResult;
try {
Expand Down
Loading