Skip to content

Commit 1100c84

Browse files
committed
better wording
1 parent ce4aad6 commit 1100c84

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlExecutionInfo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public class EsqlExecutionInfo implements ChunkedToXContentObject, Writeable {
6767
// Updates to the Cluster occur with the updateCluster method that given the key to map transforms an
6868
// old Cluster Object to a new Cluster Object with the remapping function.
6969
public final ConcurrentMap<String, Cluster> clusterInfo;
70-
// Did we initialize the clusterInfo map? If not, then we will serialize it as empty.
71-
private transient volatile boolean clusterInfoInitialized = true;
70+
// Is the clusterInfo map iinitialization in progress? If so, we should not try to serialize it.
71+
private transient volatile boolean clusterInfoInitializing;
7272
// whether the user has asked for CCS metadata to be in the JSON response (the overall took will always be present)
7373
private final boolean includeCCSMetadata;
7474

@@ -125,7 +125,7 @@ public EsqlExecutionInfo(StreamInput in) throws IOException {
125125
@Override
126126
public void writeTo(StreamOutput out) throws IOException {
127127
out.writeOptionalTimeValue(overallTook);
128-
if (clusterInfo != null && clusterInfoInitialized) {
128+
if (clusterInfo != null && clusterInfoInitializing == false) {
129129
out.writeCollection(clusterInfo.values());
130130
} else {
131131
out.writeCollection(Collections.emptyList());
@@ -352,8 +352,8 @@ public boolean isStopped() {
352352
return isStopped;
353353
}
354354

355-
public void clusterInfoInitialized(boolean clusterInfoInitialized) {
356-
this.clusterInfoInitialized = clusterInfoInitialized;
355+
public void clusterInfoInitializing(boolean clusterInfoInitializing) {
356+
this.clusterInfoInitializing = clusterInfoInitializing;
357357
}
358358

359359
/**

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,21 @@ public static void initCrossClusterState(
337337
patterns.getFirst().indexPattern()
338338
);
339339

340-
executionInfo.clusterInfoInitialized(false);
340+
executionInfo.clusterInfoInitializing(true);
341341
// initialize the cluster entries in EsqlExecutionInfo before throwing the invalid license error
342342
// so that the CCS telemetry handler can recognize that this error is CCS-related
343-
for (var entry : groupedIndices.entrySet()) {
344-
final String clusterAlias = entry.getKey();
345-
final String indexExpr = Strings.arrayToCommaDelimitedString(entry.getValue().indices());
346-
executionInfo.swapCluster(clusterAlias, (k, v) -> {
347-
assert v == null : "No cluster for " + clusterAlias + " should have been added to ExecutionInfo yet";
348-
return new EsqlExecutionInfo.Cluster(clusterAlias, indexExpr, executionInfo.isSkipUnavailable(clusterAlias));
349-
});
343+
try {
344+
for (var entry : groupedIndices.entrySet()) {
345+
final String clusterAlias = entry.getKey();
346+
final String indexExpr = Strings.arrayToCommaDelimitedString(entry.getValue().indices());
347+
executionInfo.swapCluster(clusterAlias, (k, v) -> {
348+
assert v == null : "No cluster for " + clusterAlias + " should have been added to ExecutionInfo yet";
349+
return new EsqlExecutionInfo.Cluster(clusterAlias, indexExpr, executionInfo.isSkipUnavailable(clusterAlias));
350+
});
351+
}
352+
} finally {
353+
executionInfo.clusterInfoInitializing(false);
350354
}
351-
executionInfo.clusterInfoInitialized(true);
352355
// check if it is a cross-cluster query
353356
if (groupedIndices.size() > 1 || groupedIndices.containsKey(RemoteClusterService.LOCAL_CLUSTER_GROUP_KEY) == false) {
354357
if (EsqlLicenseChecker.isCcsAllowed(licenseState) == false) {

0 commit comments

Comments
 (0)