Skip to content

Conversation

ivancea
Copy link
Contributor

@ivancea ivancea commented Jul 31, 2025

DriverStatus is an immutable record created by the Driver. However, its components are not inherently immutable.

This PR fixes a live collection used by the Driver, that was being directly put into the status, leading to ConcurrentModificationExceptions when reading it (Through the Task list API, for example).

Some example errors:

java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:134)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

And:

java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.documentsFound(DriverStatus.java:157)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:129)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at org.elasticsearch.server@9.2.0org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

Also, this looks like the source of this issue, with another similar case:
Fixes #131564

@ivancea ivancea added >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v9.2.0 v9.1.1 v8.19.1 v9.0.5 v8.17.10 v8.18.5 labels Jul 31, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Hi @ivancea, I've created a changelog YAML for you.

@nik9000 nik9000 changed the title ESQL: FIx Driver creating status with a live list of operators ESQL: Fix Driver creating status with a live list of operators Jul 31, 2025
prev.iterations() + extraIterations,
status,
statusOfCompletedOperators,
new ArrayList<>(statusOfCompletedOperators),
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably do List.copyOf here, but this is fine.

I think it's worth a comment that we always update the statusOfCompletedOperators list in this thread, but we read it in many threads.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the suggestion, and a test.

About the statusOfCompletedOperators, after this change, it's never read outside of the updateStatus()

@ivancea ivancea enabled auto-merge (squash) July 31, 2025 15:08
@ivancea ivancea merged commit 71eed0a into elastic:main Aug 1, 2025
33 checks passed
@ivancea ivancea deleted the fix-esql-driver-status-concurrency branch August 1, 2025 14:34
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.1
8.19 Commit could not be cherrypicked due to conflicts
9.0 Commit could not be cherrypicked due to conflicts
8.17 Commit could not be cherrypicked due to conflicts
8.18 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 132260

ivancea added a commit to ivancea/elasticsearch that referenced this pull request Aug 1, 2025
…ic#132260)

`DriverStatus` is an immutable record created by the Driver. However, its components are not inherently immutable.

This PR fixes a live collection used by the Driver, that was being directly put into the status, leading to `ConcurrentModificationException`s when reading it (Through the Task list API, for example).

Some example errors:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:134)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)
```
And:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.documentsFound(DriverStatus.java:157)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:129)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at org.elasticsearch.server@9.2.0org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

```

Also, this looks like the source of this issue, with another similar case:
Fixes elastic#131564
@nik9000
Copy link
Member

nik9000 commented Aug 1, 2025

Status Branch Result
9.1
❌ 8.19 Commit could not be cherrypicked due to conflicts
❌ 9.0 Commit could not be cherrypicked due to conflicts
❌ 8.17 Commit could not be cherrypicked due to conflicts
❌ 8.18 Commit could not be cherrypicked due to conflicts

Enjoy!

ivancea added a commit to ivancea/elasticsearch that referenced this pull request Aug 1, 2025
…ic#132260)

`DriverStatus` is an immutable record created by the Driver. However, its components are not inherently immutable.

This PR fixes a live collection used by the Driver, that was being directly put into the status, leading to `ConcurrentModificationException`s when reading it (Through the Task list API, for example).

Some example errors:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:134)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)
```
And:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.documentsFound(DriverStatus.java:157)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:129)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at org.elasticsearch.server@9.2.0org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

```

Also, this looks like the source of this issue, with another similar case:
Fixes elastic#131564
ivancea added a commit to ivancea/elasticsearch that referenced this pull request Aug 1, 2025
…ic#132260)

`DriverStatus` is an immutable record created by the Driver. However, its components are not inherently immutable.

This PR fixes a live collection used by the Driver, that was being directly put into the status, leading to `ConcurrentModificationException`s when reading it (Through the Task list API, for example).

Some example errors:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:134)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)
```
And:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.documentsFound(DriverStatus.java:157)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:129)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at org.elasticsearch.server@9.2.0org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

```

Also, this looks like the source of this issue, with another similar case:
Fixes elastic#131564
ivancea added a commit to ivancea/elasticsearch that referenced this pull request Aug 1, 2025
…ic#132260)

`DriverStatus` is an immutable record created by the Driver. However, its components are not inherently immutable.

This PR fixes a live collection used by the Driver, that was being directly put into the status, leading to `ConcurrentModificationException`s when reading it (Through the Task list API, for example).

Some example errors:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:134)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)
```
And:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.documentsFound(DriverStatus.java:157)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:129)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at org.elasticsearch.server@9.2.0org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

```

Also, this looks like the source of this issue, with another similar case:
Fixes elastic#131564
ivancea added a commit to ivancea/elasticsearch that referenced this pull request Aug 1, 2025
…ic#132260)

`DriverStatus` is an immutable record created by the Driver. However, its components are not inherently immutable.

This PR fixes a live collection used by the Driver, that was being directly put into the status, leading to `ConcurrentModificationException`s when reading it (Through the Task list API, for example).

Some example errors:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:134)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)
```
And:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.documentsFound(DriverStatus.java:157)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:129)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at org.elasticsearch.server@9.2.0org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

```

Also, this looks like the source of this issue, with another similar case:
Fixes elastic#131564
elasticsearchmachine pushed a commit that referenced this pull request Aug 1, 2025
…) (#132333)

`DriverStatus` is an immutable record created by the Driver. However, its components are not inherently immutable.

This PR fixes a live collection used by the Driver, that was being directly put into the status, leading to `ConcurrentModificationException`s when reading it (Through the Task list API, for example).

Some example errors:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:134)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)
```
And:
```
java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at org.elasticsearch.compute.operator.DriverStatus.documentsFound(DriverStatus.java:157)
	at org.elasticsearch.compute.operator.DriverStatus.toXContent(DriverStatus.java:129)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.value(XContentBuilder.java:993)
	at [email protected]/org.elasticsearch.xcontent.XContentBuilder.field(XContentBuilder.java:978)
	at [email protected]/org.elasticsearch.tasks.TaskInfo.toXContent(TaskInfo.java:113)
	at org.elasticsearch.server@9.2.0org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:63)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup.toXContent(TaskGroup.java:67)
	at [email protected]/org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse.lambda$groupedByParent$10(ListTasksResponse.java:183)

```

Also, this looks like the source of this issue, with another similar case:
Fixes #131564
ivancea added a commit that referenced this pull request Aug 4, 2025
ivancea added a commit that referenced this pull request Aug 4, 2025
ivancea added a commit that referenced this pull request Aug 4, 2025
ivancea added a commit that referenced this pull request Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.17.10 v8.18.5 v8.19.1 v9.0.5 v9.1.1 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] CrossClusterAsyncEnrichStopIT testEnrichAfterStop failing

4 participants