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

[Improve][Zeta] Cancel pipeline add retry to avoid cancel failed. #4792

Merged
merged 1 commit into from
May 21, 2023
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 @@ -18,6 +18,8 @@
package org.apache.seatunnel.engine.server.dag.physical;

import org.apache.seatunnel.common.utils.ExceptionUtils;
import org.apache.seatunnel.common.utils.RetryUtils;
import org.apache.seatunnel.engine.common.exception.SeaTunnelEngineException;
import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
import org.apache.seatunnel.engine.core.job.PipelineExecutionState;
Expand All @@ -34,6 +36,7 @@
import lombok.Data;
import lombok.NonNull;

import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -352,21 +355,33 @@ public boolean updatePipelineState(
}

public synchronized void cancelPipeline() {
if (getPipelineState().isEndState()) {
LOGGER.warning(
String.format(
"%s is in end state %s, can not be cancel",
pipelineFullName, getPipelineState()));
return;
}
// If an active Master Node done and another Master Node active, we can not know whether
// canceled pipeline
// complete. So we need cancel running pipeline again.
if (!PipelineStatus.CANCELING.equals(runningJobStateIMap.get(pipelineLocation))) {
updatePipelineState(getPipelineState(), PipelineStatus.CANCELING);
try {
RetryUtils.retryWithException(
() -> {
if (getPipelineState().isEndState()) {
LOGGER.warning(
String.format(
"%s is in end state %s, can not be cancel",
pipelineFullName, getPipelineState()));
return null;
}
// If an active Master Node done and another Master Node active, we can not
// know whether
// canceled pipeline
// complete. So we need cancel running pipeline again.
if (!PipelineStatus.CANCELING.equals(
runningJobStateIMap.get(pipelineLocation))) {
updatePipelineState(getPipelineState(), PipelineStatus.CANCELING);
}
cancelCheckpointCoordinator();
cancelPipelineTasks();
return null;
},
new RetryUtils.RetryMaterial(
30, true, e -> e instanceof IOException, 1000, true));
} catch (Exception e) {
throw new SeaTunnelEngineException(e);
}
cancelCheckpointCoordinator();
cancelPipelineTasks();
}

private void cancelCheckpointCoordinator() {
Expand Down