Skip to content

Reindex relocation: store source TaskResult at destination node#145488

Merged
samxbr merged 10 commits intoelastic:mainfrom
samxbr:reindex/store-source-result
Apr 8, 2026
Merged

Reindex relocation: store source TaskResult at destination node#145488
samxbr merged 10 commits intoelastic:mainfrom
samxbr:reindex/store-source-result

Conversation

@samxbr
Copy link
Copy Markdown
Contributor

@samxbr samxbr commented Apr 1, 2026

In order to make reindex management API resilient to failures, the relocation destination node needs to write the relocation source task result into .tasks index. This ensures the relocated task can be found by management APIs from following the relocation chain stored in .tasks, if source node has ungracefully failed before writing the task result into .tasks.

We also need to ensure the source task does not override the result stored by destination, this will be handled in a separate PR.

@samxbr samxbr changed the title Reindex/store source result Reindex relocation: store source TaskResult at destination node Apr 1, 2026
@samxbr samxbr added :Distributed/Reindex Issues relating to reindex that are not caused by issues further down >non-issue labels Apr 1, 2026
@samxbr samxbr marked this pull request as ready for review April 1, 2026 21:50
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team. label Apr 1, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@szybia
Copy link
Copy Markdown
Contributor

szybia commented Apr 2, 2026

just looked at overall approach, and spotted this: #145488 (comment)

so asking before proceeding since might mean a rework, unless i'm missing something

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves reindex relocation resilience by ensuring the relocation destination node persists the relocation source task’s result into the .tasks system index, so reindex management APIs can still follow the relocation chain if the source node fails before writing its own result.

Changes:

  • Plumbs TaskResultsService into reindex transport/actions and Reindexer so the destination can write the source task result into .tasks.
  • Extends relocation resume payload (ResumeInfo) to carry the source TaskResult across to the destination node.
  • Updates tests to validate that the source task result is transmitted/stored and that management APIs continue to follow relocation chains.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/TransportEnrichReindexAction.java Adds TaskResultsService wiring for enrich’s specialized reindex transport action.
server/src/main/java/org/elasticsearch/tasks/TaskResult.java Adds a helper to produce a new TaskResult with a replaced error payload.
server/src/main/java/org/elasticsearch/index/reindex/ResumeInfo.java Adds sourceTaskResult to relocation resume info and serializes it over the wire.
modules/reindex/src/main/java/org/elasticsearch/reindex/TransportReindexAction.java Injects TaskResultsService and passes it into Reindexer.
modules/reindex/src/main/java/org/elasticsearch/reindex/Reindexer.java Stores the source task result on the destination node before continuing execution; includes source result in resume request.
modules/reindex/src/main/java/org/elasticsearch/reindex/TaskRelocatedException.java Introduces a constructor to populate relocation metadata directly (replaces setter-style API).
modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexerTests.java Adds unit tests for transmitting/storing the source task result and failure handling.
modules/reindex-management/src/test/java/org/elasticsearch/reindex/management/TransportGetReindexActionTests.java Updates tests to use the new TaskRelocatedException constructor.
modules/reindex-management/src/internalClusterTest/java/org/elasticsearch/reindex/management/ReindexRelocationIT.java Adds an IT intended to verify destination-side .tasks write preserves the relocation chain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@szybia szybia left a comment

Choose a reason for hiding this comment

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

nothing blocking, LGTM!

i guess have a scan at comments and see whether you agree, can be done as follow-up PR too

@samxbr
Copy link
Copy Markdown
Contributor Author

samxbr commented Apr 8, 2026

nothing blocking, LGTM!

i guess have a scan at comments and see whether you agree, can be done as follow-up PR too

Thanks for the comments. I am inclined to merge this PR first since it's blocking my next PRs, in which I will also address theses comments.

@samxbr samxbr merged commit 867e120 into elastic:main Apr 8, 2026
39 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Apr 8, 2026
…cation

* upstream/main:
  Reindex relocation: store source TaskResult at destination node (elastic#145488)
  Bump versions after 9.2.8 release
  [CI] DLMFrozenTransitionServiceTests testCheckForFrozenIndicesReturnsEarlyWhenCapacityExhausted failing [elastic#145778] (elastic#145906)
  Update branches.json for 9.2.8 release
  ESQL: Clarify inheriting from Attributes (elastic#145898)
  Bump versions after 9.3.3 release
  Update branches.json for 9.3.3 release
szybia added a commit to szybia/elasticsearch that referenced this pull request Apr 8, 2026
* upstream/main:
  Mute org.elasticsearch.xpack.esql.expression.function.aggregate.FirstDocIdGroupingAggregatorFunctionTests testSimple elastic#145923
  Reindex relocation: store source TaskResult at destination node (elastic#145488)
  Bump versions after 9.2.8 release
  [CI] DLMFrozenTransitionServiceTests testCheckForFrozenIndicesReturnsEarlyWhenCapacityExhausted failing [elastic#145778] (elastic#145906)
  Update branches.json for 9.2.8 release
  ESQL: Clarify inheriting from Attributes (elastic#145898)
  Bump versions after 9.3.3 release
  Update branches.json for 9.3.3 release
  Prune changelogs after 8.19.14 release
  Bump versions after 8.19.14 release
  Update branches.json for 8.19.14 release
  [ML] Call old inference API (elastic#145690)
  ESQL: Unmute CsvIT sumWithOverflowRow (elastic#145893)
  Index a document when testing runtime fields shadowing dimensions & metrics (elastic#145882)
  [TEST] Fix version check in testSequenceNumbersDisabled (elastic#145879)
  [ESQL] Per-file filter pushdown awareness (elastic#145755)
  Unmute testGetReindexFollowsRelocation (elastic#145841)
  Correctly ignore system indices when validating dot-prefixed indices (elastic#128868)
  [Transform] Remove tests for deleted code (elastic#145685)
  ESQL: Add generative tests for LIMIT BY (elastic#144238)
joshua-adams-1 added a commit to joshua-adams-1/elasticsearch that referenced this pull request Apr 9, 2026
I merged elastic#145803 but it conflicted with elastic#145488 merged yesterday
@samxbr
Copy link
Copy Markdown
Contributor Author

samxbr commented Apr 9, 2026

nothing blocking, LGTM!
i guess have a scan at comments and see whether you agree, can be done as follow-up PR too

Thanks for the comments. I am inclined to merge this PR first since it's blocking my next PRs, in which I will also address theses comments.

Follow up PR #145947 that includes improvements suggested in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Reindex Issues relating to reindex that are not caused by issues further down >non-issue Team:Distributed Meta label for distributed team. v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants