Skip to content

Conversation

@szybia
Copy link
Contributor

@szybia szybia commented Dec 8, 2025

  • Add new API to cancel a reindex task
  • All functionality hidden behind feature flag so shouldn't affect release at all
  • This PR contains core functionality of the endpoint to keep reviews more scoped/focused, noting my todo list (will update as I open PRs):
  • Tests for filtering tasks logic
  • Add ReindexFeatures to guard reject requests to _cancel on mixed-clusters (ran into some issues)
  • Return same response with ?wait_for_completion=true as incoming GET _reindex/{taskId}
  • Serialization tests for Request/Response (needs a few random changes so not cluttering this PR)
  • Any changes we agree on regarding behavior when we cancel a non-running task

Let me know if there's any other action items I haven't considered :)

}

final var response = new CancelReindexResponse(taskFailures, nodeExceptions);
response.rethrowFailures("cancel_reindex"); // if we haven't handled any exception already, throw here
Copy link
Contributor Author

Choose a reason for hiding this comment

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

mainly means a HTTP 500

i can't think of other failures to handle, but assume it's fine if we run into something and we fix it to be handled later rather than passively returning a 200 with failure in response or something


taskManager.cancelTaskAndDescendants(
task,
CancelTasksRequest.DEFAULT_REASON,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

public static final String DEFAULT_REASON = "by user request";

final TaskId taskId = request.getTargetTaskId();
assert taskId.isSet() : "task id must be provided";

final CancellableTask task = taskManager.getCancellableTask(taskId.getId());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

UTs incoming for this filtering logic...

@szybia szybia added >non-issue :Distributed Indexing/Reindex Issues relating to reindex that are not caused by issues further down labels Dec 9, 2025
@szybia szybia force-pushed the reindex-cancel-api branch from 654cb1d to 10bf116 Compare December 9, 2025 12:12
@szybia szybia marked this pull request as ready for review December 9, 2025 12:20
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Indexing Meta label for Distributed Indexing team label Dec 9, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@szybia
Copy link
Contributor Author

szybia commented Dec 9, 2025

note to self: test that my ITs are skipped in release build by applying label

throw new IllegalArgumentException("invalid taskId provided: " + taskIdParam);
}

final ProjectId projectId = client.projectResolver().getProjectId();
Copy link
Contributor

Choose a reason for hiding this comment

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

There had been discussion before on whether to expose project id at the rest layer, and I think we didn't have a settlement yet before the multi-project project was paused. But if I remember correctly the tentative general guidance was to push the multi project resolving to the transport layer if possible. It saves the boilerplate for project id in all the requests.

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 makes sense, given headers seem to be transmitted with every transport request anyway

* upstream/main: (79 commits)
  Mute org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT test {p0=search/140_pre_filter_search_shards/prefilter on non-indexed date fields} elastic#139381
  Adjust error bounds for bfloat16 value checks (elastic#139371)
  Unmute some vector CSS tests (elastic#139370)
  Do not allow `project_routing` as a query param (elastic#139206)
  Unmute HalfFloat...Tests#testSynthesizeArrayRandom (elastic#139341)
  Remove leniency in LinkedProjectConfig builder methods (elastic#139012)
  EQL: fix project_routing (elastic#139366)
  Add patch version for 9.2 index version constant (elastic#139362)
  Mute org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT test {p0=search.vectors/200_dense_vector_docvalue_fields/dense_vector docvalues with bfloat16} elastic#139368
  ES|QL: Enable CCS tests for FORK (elastic#139302)
  Restructuring the semantic_text field type page  (elastic#138571)
  AggregateMetricDouble fields should not build BKD indexes (elastic#138724)
  Feature/count by trunc with filter (elastic#138765)
  ESQL: Convert TS 500 error to 400 (elastic#139360)
  [CI] Rerun failing tests for periodic build pipelines (elastic#139200)
  revert muting saml test (elastic#139327)
  Add TDigest histogram as metric (elastic#139247)
  Links solved bugs to class cast exception changelog and unmutes errors (elastic#139340)
  Ensure integer sorts are rewritten to long sorts for BWC indexes (elastic#139293)
  Integrate stored fields format bloom filter with synthetic _id (elastic#138515)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants