Skip to content

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Aug 12, 2025

Some fixes around AsyncOperator.Status:

  • Fix its pages received/emitted, that were -1 of what they should be (And removed the "Max(0, ...)" to avoid falsifying it
  • Added the emitted_rows field to LookupFromIndexOperator.Status, which was missing, and would add interesting data on join results
  • Added better testing support for Status checks after a Driver run

@ivancea ivancea added >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.2.0 labels Aug 12, 2025
@ivancea ivancea changed the title ESQL: Fix Driver finishing before AsyncOperator listener ESQL: (WIP) Fix Driver finishing before AsyncOperator listener Aug 12, 2025
@ivancea ivancea changed the title ESQL: (WIP) Fix Driver finishing before AsyncOperator listener ESQL: Fix AsyncOperator status values and add emitted rows Aug 13, 2025
Comment on lines 162 to 164
assertThat(map, hasEntry(is("received_pages"), nonNegativeMatcher));
assertThat(map, hasEntry(is("completed_pages"), nonNegativeMatcher));
assertThat(map, hasEntry(is("process_nanos"), nonNegativeMatcher));
Copy link
Contributor Author

@ivancea ivancea Aug 13, 2025

Choose a reason for hiding this comment

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

The async operator status fields are serialized as "received_pages" instead of "pages_received" (Like the others operators).
Should I normalize it here? It's not even a transport version change, just some unit tests

Copy link
Member

Choose a reason for hiding this comment

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

++ to make this consistent with the other operators.

@ivancea ivancea added >bug and removed >non-issue labels Aug 13, 2025
@ivancea ivancea marked this pull request as ready for review August 13, 2025 13:45
@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.

@dnhatn dnhatn self-requested a review August 13, 2025 14:40
Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

@ivancea Thanks for fixing this. LGTM!

Comment on lines 162 to 164
assertThat(map, hasEntry(is("received_pages"), nonNegativeMatcher));
assertThat(map, hasEntry(is("completed_pages"), nonNegativeMatcher));
assertThat(map, hasEntry(is("process_nanos"), nonNegativeMatcher));
Copy link
Member

Choose a reason for hiding this comment

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

++ to make this consistent with the other operators.

@Override
public final Operator.Status status() {
return status(Math.max(0L, checkpoint.getMaxSeqNo()), Math.max(0L, checkpoint.getProcessedCheckpoint()), processNanos.sum());
return status(checkpoint.getMaxSeqNo() + 1, checkpoint.getProcessedCheckpoint() + 1, processNanos.sum());
Copy link
Member

Choose a reason for hiding this comment

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

👍 These are correct usages.

ivancea added a commit that referenced this pull request Aug 14, 2025
)

Fixes #128030
Fixes #130296
Fixes #130642
Fixes #131148
Fixes #132554
Fixes #132555
Fixes #132604
Fixes #131563
Fixes #132778

Extracted from #132738

An AsyncOperator listener misordering caused the warnings collection and status metrics updates to be executed after the `onSeqNoCompleted()`>`notifyIfBlocked()`>`future.onResponse(null)`, which ends the processing in some cases.
# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexOperator.java
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexOperatorStatusTests.java
joshua-adams-1 pushed a commit to joshua-adams-1/elasticsearch that referenced this pull request Aug 14, 2025
…tic#132744)

Fixes elastic#128030
Fixes elastic#130296
Fixes elastic#130642
Fixes elastic#131148
Fixes elastic#132554
Fixes elastic#132555
Fixes elastic#132604
Fixes elastic#131563
Fixes elastic#132778

Extracted from elastic#132738

An AsyncOperator listener misordering caused the warnings collection and status metrics updates to be executed after the `onSeqNoCompleted()`>`notifyIfBlocked()`>`future.onResponse(null)`, which ends the processing in some cases.
ivancea and others added 6 commits August 19, 2025 15:27
# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
#	x-pack/plugin/esql/compute/test/src/main/java/org/elasticsearch/compute/test/AnyOperatorTestCase.java
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexOperatorTests.java
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/inference/InferenceOperatorTestCase.java
@ivancea ivancea added the test-release Trigger CI checks against release build label Aug 20, 2025
Comment on lines 172 to 194
/**
* EqualTo matcher that takes care of whole number types (Integers and longs).
*/
protected final Matcher<Object> matchNumberEqualTo(Number value) {
return wholeMatcher(comparesEqualTo(value.intValue()), comparesEqualTo(value.longValue()));
}

/**
* GreaterThanOrEqualTo matcher that takes care of whole number types (Integers and longs).
*/
protected final Matcher<Object> matchNumberGreaterThanOrEqualTo(Number value) {
return wholeMatcher(greaterThanOrEqualTo(value.intValue()), greaterThanOrEqualTo(value.longValue()));
}

/**
* Matcher that matches based on the number type (Integer or long).
*/
@SuppressWarnings("unchecked")
protected final Matcher<Object> wholeMatcher(Matcher<Integer> integerMatcher, Matcher<Long> longMatcher) {
return either(both(instanceOf(Integer.class)).and((Matcher<? super Object>) (Matcher<?>) integerMatcher)).or(
both(instanceOf(Long.class)).and((Matcher<? super Object>) (Matcher<?>) longMatcher)
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without those, we can't safely make a "greater than 0" matcher, for example, as it could be either an int or a long. This takes care of that. I couldn't find a better option.

Copy link
Member

Choose a reason for hiding this comment

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

either(greaterThan(0)).or(greaterThan(0L))?

I found that they always made 0 the Integer when deserializing unless the result is huge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed! It required some not-technically-correct casts, but worked fine

Comment on lines 172 to 194
/**
* EqualTo matcher that takes care of whole number types (Integers and longs).
*/
protected final Matcher<Object> matchNumberEqualTo(Number value) {
return wholeMatcher(comparesEqualTo(value.intValue()), comparesEqualTo(value.longValue()));
}

/**
* GreaterThanOrEqualTo matcher that takes care of whole number types (Integers and longs).
*/
protected final Matcher<Object> matchNumberGreaterThanOrEqualTo(Number value) {
return wholeMatcher(greaterThanOrEqualTo(value.intValue()), greaterThanOrEqualTo(value.longValue()));
}

/**
* Matcher that matches based on the number type (Integer or long).
*/
@SuppressWarnings("unchecked")
protected final Matcher<Object> wholeMatcher(Matcher<Integer> integerMatcher, Matcher<Long> longMatcher) {
return either(both(instanceOf(Integer.class)).and((Matcher<? super Object>) (Matcher<?>) integerMatcher)).or(
both(instanceOf(Long.class)).and((Matcher<? super Object>) (Matcher<?>) longMatcher)
);
}
Copy link
Member

Choose a reason for hiding this comment

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

either(greaterThan(0)).or(greaterThan(0L))?

I found that they always made 0 the Integer when deserializing unless the result is huge.

# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
@ivancea ivancea enabled auto-merge (squash) August 21, 2025 10:42
@ivancea ivancea merged commit 6066ac4 into elastic:main Aug 21, 2025
34 checks passed
@ivancea ivancea deleted the esql-lookup-warnings-status-race branch August 21, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) test-release Trigger CI checks against release build v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants