Skip to content

Commit

Permalink
[Transform] Make _reset action stop transforms without force first
Browse files Browse the repository at this point in the history
  • Loading branch information
przemekwitek committed Jan 29, 2024
1 parent ed6e8ec commit 331015f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public void cleanup() throws Exception {
cleanUp();
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/104825")
@SuppressWarnings("unchecked")
public void testTransformFeatureReset() throws Exception {
String indexName = "basic-crud-reviews";
Expand Down Expand Up @@ -90,6 +89,9 @@ public void testTransformFeatureReset() throws Exception {
.build();

putTransform(continuousTransformId, Strings.toString(config), RequestOptions.DEFAULT);

Thread.sleep(randomLongBetween(0, 5_000));

startTransform(continuousTransformId, RequestOptions.DEFAULT);

assertOK(client().performRequest(new Request(HttpPost.METHOD_NAME, "/_features/_reset")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public void cleanUpFeature(
SystemIndexPlugin.super.cleanUpFeature(clusterService, client, unsetResetModeListener);
}, unsetResetModeListener::onFailure);

ActionListener<StopTransformAction.Response> afterStoppingTransforms = ActionListener.wrap(stopTransformsResponse -> {
ActionListener<StopTransformAction.Response> afterForceStoppingTransforms = ActionListener.wrap(stopTransformsResponse -> {
if (stopTransformsResponse.isAcknowledged()
&& stopTransformsResponse.getTaskFailures().isEmpty()
&& stopTransformsResponse.getNodeFailures().isEmpty()) {
Expand Down Expand Up @@ -439,12 +439,28 @@ public void cleanUpFeature(
}
}, unsetResetModeListener::onFailure);

ActionListener<StopTransformAction.Response> afterStoppingTransforms = ActionListener.wrap(
afterForceStoppingTransforms::onResponse,
e -> {
logger.warn("Exception while trying to stop the transforms, will try again with force=true", e);
StopTransformAction.Request forceStopTransformsRequest = new StopTransformAction.Request(
Metadata.ALL,
true,
true,
null,
true,
false
);
client.execute(StopTransformAction.INSTANCE, forceStopTransformsRequest, afterForceStoppingTransforms);
}
);

ActionListener<AcknowledgedResponse> afterResetModeSet = ActionListener.wrap(response -> {
StopTransformAction.Request stopTransformsRequest = new StopTransformAction.Request(
Metadata.ALL,
true,
true,
null,
false,
TimeValue.timeValueSeconds(10),
true,
false
);
Expand Down

0 comments on commit 331015f

Please sign in to comment.