Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Replace the scroll with PIT for data batching #62488

Closed
wants to merge 21 commits into from

Conversation

bpintea
Copy link
Contributor

@bpintea bpintea commented Sep 16, 2020

This PR will replace usage of the scroll API in the SQL module with the new point-in-time API.

Closes #61873

This commit migrates the ScrollCursor and CompositeAggCursor cursors and
their dependencies away from using the scroll API to using the new PIT
feature.
REST-closing a cursor after resultset exhaustion no longer needs to be
done "manually", this is taken care by the cursor implementation.
Implicit grouping queries are one-shot requests, no pagination every
needed, so don't start a PIT for them.
PIT won't (can't) keep the state of last served document when
paginating with search_after. In order to correctly paginate also in
cases when the sorting order is not done by a strictly monotone
criterion (missing or repeating values, script-sorting), we need to have
the _doc part of the (returned/reused) sorting key.
Fix test after upstream merge.
Rework ResultCursor class to correct the tracking of the "after" map for
comp. aggs.
PIT doesn't seem to bind the user, as the scroll does -- disable the
test supposed to fail on user A employing the PIT generated by user B.
@bpintea
Copy link
Contributor Author

bpintea commented Sep 17, 2020

@elasticmachine update branch

elasticmachine and others added 4 commits September 16, 2020 23:57
s/@Ignore/@AwaitsFix
- further translation tests fixes.
- remove PIT keep_alive value from first SQL request PIT object.
The resuming of an order request needs to take into account the _index
as well for the case the queried "table" is an alias.
@bpintea
Copy link
Contributor Author

bpintea commented Sep 17, 2020

@elasticmachine update branch

elasticmachine and others added 3 commits September 17, 2020 13:55
Update translation tests with new sorting source, _index.
Unlike the scroll, the PIT can be shared by multiple users, so this test
becomes obsolete.
@bpintea
Copy link
Contributor Author

bpintea commented Sep 18, 2020

@elasticmachine update branch

@bpintea bpintea marked this pull request as ready for review September 21, 2020 10:15
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (:Query Languages/SQL)

@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Sep 21, 2020
Comment on lines -1028 to -1034
Map<String, Object> response = runSql(
new StringEntity(cursor(cursor).toString(), ContentType.APPLICATION_JSON),
"/close",
Mode.PLAIN.toString()
);
assertEquals(true, response.get("succeeded"));

Copy link
Contributor Author

@bpintea bpintea Sep 21, 2020

Choose a reason for hiding this comment

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

This is no longer required, the SearchHit cursor wasn't properly auto-closed on result set exhaustion, but it is now.

@@ -49,7 +49,7 @@ static int remainingData(boolean hasNextPage, int size, int limit) {
if (hasNextPage == false) {
return 0;
} else {
int remainingLimit = (limit == -1) ? limit : ((limit - size) >= 0 ? (limit - size) : 0);
int remainingLimit = limit == -1 ? limit : Math.max(limit - size, 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change done to compact the expression and match the similar construct in the constructor (above).

@bpintea bpintea requested review from matriv, astefan and costin and removed request for matriv September 21, 2020 10:33
@andreidan andreidan added v7.11.0 and removed v7.10.0 labels Oct 7, 2020
@costin costin removed the request for review from matriv July 8, 2021 16:23
@danhermann danhermann added v8.1.0 and removed v7.16.0 labels Oct 27, 2021
@arteam arteam removed the v8.0.0 label Jan 12, 2022
@mark-vieira mark-vieira added v8.2.0 and removed v8.1.0 labels Feb 2, 2022
@elasticsearchmachine
Copy link
Collaborator

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

@bpintea
Copy link
Contributor Author

bpintea commented Mar 9, 2022

Superseded by #83381 and #84605.

@bpintea bpintea closed this Mar 9, 2022
@bpintea bpintea deleted the enh/replace_scroll_with_pit branch March 9, 2022 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/SQL SQL querying >enhancement Team:QL (Deprecated) Meta label for query languages team v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL: replace the scroll with PIT for data batching
10 participants