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

[ML-DataFrame] improve error message for timeout case in stop #46131

Merged
merged 2 commits into from
Sep 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,55 @@ private void waitForDataFrameStopped(Set<String> persistentTaskIds,

listener.onFailure(new ElasticsearchStatusException(message, RestStatus.CONFLICT));
},
listener::onFailure
e -> {
// waitForPersistentTasksCondition throws a IllegalStateException on timeout
if (e instanceof IllegalStateException && e.getMessage().startsWith("Timed out")) {
PersistentTasksCustomMetaData persistentTasksCustomMetaData = clusterService.state().metaData()
.custom(PersistentTasksCustomMetaData.TYPE);

if (persistentTasksCustomMetaData == null) {
listener.onResponse(new Response(Boolean.TRUE));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
listener.onResponse(new Response(Boolean.TRUE));
listener.onResponse(new Response(Boolean.TRUE));
return;

return;
}

// collect which tasks are still running
Set<String> stillRunningTasks = new HashSet<>();
for (String persistentTaskId : persistentTaskIds) {
if (persistentTasksCustomMetaData.getTask(persistentTaskId) != null) {
stillRunningTasks.add(persistentTaskId);
}
}

if (stillRunningTasks.isEmpty()) {
// should not happen
listener.onResponse(new Response(Boolean.TRUE));
return;
} else {
StringBuilder message = new StringBuilder();
if (persistentTaskIds.size() - stillRunningTasks.size() - exceptions.size() > 0) {
message.append("Successfully stopped [");
message.append(persistentTaskIds.size() - stillRunningTasks.size() - exceptions.size());
message.append("] transforms. ");
}

if (exceptions.size() > 0) {
message.append("Could not stop the transforms ");
message.append(exceptions.keySet());
message.append(" as they were failed. Use force stop to stop the transforms. ");
}

if (stillRunningTasks.size() > 0) {
message.append("Could not stop the transforms ");
message.append(stillRunningTasks);
message.append(" as they timed out.");
}

listener.onFailure(new ElasticsearchStatusException(message.toString(), RestStatus.REQUEST_TIMEOUT));
return;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
return;
}

Or wrap the other listener.onFailure(e); in an else block. Seems to me there is a chance for the listener to be called twice.

listener.onFailure(e);
}
));
}
}