|
@@ -82,6 +82,7 @@ import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.Executor;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
+import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
|
import static org.elasticsearch.xpack.esql.plugin.EsqlPlugin.ESQL_WORKER_THREAD_POOL_NAME;
|
|
|
|
|
@@ -101,6 +102,7 @@ public class ComputeService {
|
|
|
private final EnrichLookupService enrichLookupService;
|
|
|
private final LookupFromIndexService lookupFromIndexService;
|
|
|
private final ClusterService clusterService;
|
|
|
+ private final AtomicLong childSessionIdGenerator = new AtomicLong();
|
|
|
|
|
|
public ComputeService(
|
|
|
SearchService searchService,
|
|
@@ -167,7 +169,7 @@ public class ComputeService {
|
|
|
return;
|
|
|
}
|
|
|
var computeContext = new ComputeContext(
|
|
|
- sessionId,
|
|
|
+ newChildSession(sessionId),
|
|
|
RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY,
|
|
|
List.of(),
|
|
|
configuration,
|
|
@@ -330,14 +332,15 @@ public class ComputeService {
|
|
|
// the new remote exchange sink, and initialize the computation on the target node via data-node-request.
|
|
|
for (DataNode node : dataNodeResult.dataNodes()) {
|
|
|
var queryPragmas = configuration.pragmas();
|
|
|
+ var childSessionId = newChildSession(sessionId);
|
|
|
ExchangeService.openExchange(
|
|
|
transportService,
|
|
|
node.connection,
|
|
|
- sessionId,
|
|
|
+ childSessionId,
|
|
|
queryPragmas.exchangeBufferSize(),
|
|
|
esqlExecutor,
|
|
|
refs.acquire().delegateFailureAndWrap((l, unused) -> {
|
|
|
- var remoteSink = exchangeService.newRemoteSink(parentTask, sessionId, transportService, node.connection);
|
|
|
+ var remoteSink = exchangeService.newRemoteSink(parentTask, childSessionId, transportService, node.connection);
|
|
|
exchangeSource.addRemoteSink(remoteSink, queryPragmas.concurrentExchangeClients());
|
|
|
ActionListener<ComputeResponse> computeResponseListener = computeListener.acquireCompute(clusterAlias);
|
|
|
var dataNodeListener = ActionListener.runBefore(computeResponseListener, () -> l.onResponse(null));
|
|
@@ -345,7 +348,7 @@ public class ComputeService {
|
|
|
node.connection,
|
|
|
DATA_ACTION_NAME,
|
|
|
new DataNodeRequest(
|
|
|
- sessionId,
|
|
|
+ childSessionId,
|
|
|
configuration,
|
|
|
clusterAlias,
|
|
|
node.shardIds,
|
|
@@ -378,17 +381,18 @@ public class ComputeService {
|
|
|
var linkExchangeListeners = ActionListener.releaseAfter(computeListener.acquireAvoid(), exchangeSource.addEmptySink());
|
|
|
try (RefCountingListener refs = new RefCountingListener(linkExchangeListeners)) {
|
|
|
for (RemoteCluster cluster : clusters) {
|
|
|
+ final var childSessionId = newChildSession(sessionId);
|
|
|
ExchangeService.openExchange(
|
|
|
transportService,
|
|
|
cluster.connection,
|
|
|
- sessionId,
|
|
|
+ childSessionId,
|
|
|
queryPragmas.exchangeBufferSize(),
|
|
|
esqlExecutor,
|
|
|
refs.acquire().delegateFailureAndWrap((l, unused) -> {
|
|
|
- var remoteSink = exchangeService.newRemoteSink(rootTask, sessionId, transportService, cluster.connection);
|
|
|
+ var remoteSink = exchangeService.newRemoteSink(rootTask, childSessionId, transportService, cluster.connection);
|
|
|
exchangeSource.addRemoteSink(remoteSink, queryPragmas.concurrentExchangeClients());
|
|
|
var remotePlan = new RemoteClusterPlan(plan, cluster.concreteIndices, cluster.originalIndices);
|
|
|
- var clusterRequest = new ClusterComputeRequest(cluster.clusterAlias, sessionId, configuration, remotePlan);
|
|
|
+ var clusterRequest = new ClusterComputeRequest(cluster.clusterAlias, childSessionId, configuration, remotePlan);
|
|
|
var clusterListener = ActionListener.runBefore(
|
|
|
computeListener.acquireCompute(cluster.clusterAlias()),
|
|
|
() -> l.onResponse(null)
|
|
@@ -912,4 +916,8 @@ public class ComputeService {
|
|
|
return searchContexts.stream().map(ctx -> ctx.getSearchExecutionContext()).toList();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private String newChildSession(String session) {
|
|
|
+ return session + "/" + childSessionIdGenerator.incrementAndGet();
|
|
|
+ }
|
|
|
}
|