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

Use the remaining scroll response documents on update by query bulk requests #71430

Merged
merged 22 commits into from
Apr 20, 2021

Conversation

fcofdez
Copy link
Contributor

@fcofdez fcofdez commented Apr 7, 2021

In update by query requests where max_docs < size and conflicts=proceed
we weren't using the remaining documents from the scroll response in
cases where there were conflicts and in the first bulk request the
successful updates < max_docs. This commit address that problem and
use the remaining documents from the scroll response instead of
requesting a new page.

Closes #63671

…equests

In update by query requests where max_docs < size and conflicts=proceed
we weren't using the remaining documents from the scroll response in
cases where there were conflicts and in the first bulk request the
successful updates < max_docs. This commit address that problem and
use the remaining documents from the scroll response instead of
requesting a new page.

Closes elastic#63671
@fcofdez fcofdez changed the title [WIP] Update by query conflicts [WIP] @fcofdez Use the remaining scroll response documents on update by query bulk requests Apr 8, 2021
@fcofdez fcofdez changed the title [WIP] @fcofdez Use the remaining scroll response documents on update by query bulk requests [WIP] Use the remaining scroll response documents on update by query bulk requests Apr 8, 2021
@fcofdez fcofdez changed the title [WIP] Use the remaining scroll response documents on update by query bulk requests Use the remaining scroll response documents on update by query bulk requests Apr 8, 2021
@fcofdez fcofdez added Team:Distributed Meta label for distributed team :Distributed/Reindex Issues relating to reindex that are not caused by issues further down v8.0.0 v7.13.0 >bug labels Apr 8, 2021
@fcofdez fcofdez marked this pull request as ready for review April 8, 2021 09:48
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

I left a few comments. Also, I would like to have the documentation refined to make it clear how max_docs now work with conflicts in all 3 cases (reindex, update and delete by query).

@fcofdez
Copy link
Contributor Author

fcofdez commented Apr 14, 2021

@elasticmachine run elasticsearch-ci/packaging-sample-unix

00:25:32.523 BUILD SUCCESSFUL in 24m 43s
00:25:32.523 448 actionable tasks: 363 executed, 85 from cache
00:25:32.623 
00:25:32.623 Publishing build scan...
00:25:32.823 
00:25:33.564 runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
00:25:33.564 runbld>>> DURATION: 1485789ms
00:25:33.565 runbld>>> STDOUT: 34881 bytes
00:25:33.565 runbld>>> STDERR: 0 bytes
00:25:33.565 runbld>>> WRAPPED PROCESS: SUCCESS (0)
00:25:33.565 runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/elastic+elasticsearch+pull-request+packaging-tests-unix-gcp-sample/PACKAGING_TASK/destructiveDistroTest.archives/os/centos-7-packaging
00:25:34.764 runbld>>> Storing build metadata: 
00:25:34.764 runbld>>> Adding test report.
00:25:34.764 runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/elastic+elasticsearch+pull-request+packaging-tests-unix-gcp-sample/PACKAGING_TASK/destructiveDistroTest.archives/os/centos-7-packaging
00:25:35.877 runbld>>> Found 64 test output files
00:25:36.431 runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 584 Skipped: 474
08:00:37.041 Build timed out (after 480 minutes). Marking the build as failed.
08:00:37.063 Build was aborted

Some of the builds running on centos were timing out yesterday and it seems to be a known problem.

@fcofdez
Copy link
Contributor Author

fcofdez commented Apr 19, 2021

@henningandersen could you take a look into this PR when you have the chance? Thanks!

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

Thanks for the updates here, looks good. I have a few more comments.

docs/reference/docs/reindex.asciidoc Show resolved Hide resolved
true,
(bulkByScrollResponse, maxDocs, conflictingUpdates) -> {
assertThat(bulkByScrollResponse.getUpdated(), is((long) maxDocs));
assertThat(bulkByScrollResponse.getVersionConflicts(), is((long) conflictingUpdates));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can move this assertion into the generic test case (executeConcurrentUpdatesOnSubsetOfDocs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tackled in 9fe5874

// Modify a subset of the target documents concurrently
final List<SearchHit> originalDocs = Arrays.asList(searchResponse.getHits().getHits());
final List<SearchHit> docsModifiedConcurrently = new ArrayList<>();
if (randomBoolean()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a case where we run out of docs on the query, i.e., we end up updating less than max_docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tackled in 9fe5874

static class ScrollConsumableHitsResponse {
private final ScrollableHitSource.AsyncResponse asyncResponse;
private final List<? extends ScrollableHitSource.Hit> hits;
private final AtomicInteger consumedOffset = new AtomicInteger(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can just be an int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That offset can be updated from different threads, as AbstractAsyncBulkByScrollAction#prepareBulkRequest runs in the GENERIC thread pool, after throttling has been applied.

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

LGTM.

@fcofdez
Copy link
Contributor Author

fcofdez commented Apr 20, 2021

@elasticmachine update branch

@fcofdez fcofdez merged commit 9d8fb9f into elastic:master Apr 20, 2021
fcofdez added a commit to fcofdez/elasticsearch that referenced this pull request Apr 20, 2021
…equests

In update by query requests where max_docs < size and conflicts=proceed
we weren't using the remaining documents from the scroll response in
cases where there were conflicts and in the first bulk request the
successful updates < max_docs. This commit address that problem and
use the remaining documents from the scroll response instead of
requesting a new page.

Closes elastic#63671
Backport of elastic#71430
fcofdez added a commit that referenced this pull request Apr 20, 2021
…equests (#71931)

In update by query requests where max_docs < size and conflicts=proceed
we weren't using the remaining documents from the scroll response in
cases where there were conflicts and in the first bulk request the
successful updates < max_docs. This commit address that problem and
use the remaining documents from the scroll response instead of
requesting a new page.

Closes #63671
Backport of #71430
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/Reindex Issues relating to reindex that are not caused by issues further down Team:Distributed Meta label for distributed team v7.13.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update by query and max_docs and conficts=proceed
4 participants