@@ -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