@@ -67,6 +67,8 @@ public class EsqlExecutionInfo implements ChunkedToXContentObject, Writeable {
67
67
// Updates to the Cluster occur with the updateCluster method that given the key to map transforms an
68
68
// old Cluster Object to a new Cluster Object with the remapping function.
69
69
public final ConcurrentMap <String , Cluster > clusterInfo ;
70
+ // Is the clusterInfo map iinitialization in progress? If so, we should not try to serialize it.
71
+ private transient volatile boolean clusterInfoInitializing ;
70
72
// whether the user has asked for CCS metadata to be in the JSON response (the overall took will always be present)
71
73
private final boolean includeCCSMetadata ;
72
74
@@ -124,10 +126,8 @@ public EsqlExecutionInfo(StreamInput in) throws IOException {
124
126
@ Override
125
127
public void writeTo (StreamOutput out ) throws IOException {
126
128
out .writeOptionalTimeValue (overallTook );
127
- if (clusterInfo != null ) {
128
- // .stream().toList() creates an immutable copy of the cluster info entries
129
- // as today they might be still changing while serialization is happening
130
- out .writeCollection (clusterInfo .values ().stream ().toList ());
129
+ if (clusterInfo != null && clusterInfoInitializing == false ) {
130
+ out .writeCollection (clusterInfo .values ());
131
131
} else {
132
132
out .writeCollection (Collections .emptyList ());
133
133
}
@@ -354,6 +354,10 @@ public boolean isStopped() {
354
354
return isStopped ;
355
355
}
356
356
357
+ public void clusterInfoInitializing (boolean clusterInfoInitializing ) {
358
+ this .clusterInfoInitializing = clusterInfoInitializing ;
359
+ }
360
+
357
361
/**
358
362
* Represents the search metadata about a particular cluster involved in a cross-cluster search.
359
363
* The Cluster object can represent either the local cluster or a remote cluster.
0 commit comments