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

fix(partition-plan): task's status is not as expected when error strategy is set to 'ignore any errors' #3805

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
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 @@ -108,7 +108,8 @@ protected DatabaseChangeResult start(Long taskId, TaskService taskService, Deleg
DatabaseChangeResult result;
try {
log.info("Async task starts, taskId={}, activityId={}", taskId, execution.getCurrentActivityId());
asyncTaskThread = generateOdcAsyncTaskThread(taskId, execution);
DatabaseChangeParameters parameters = FlowTaskUtil.getAsyncParameter(execution);
asyncTaskThread = generateOdcAsyncTaskThread(taskId, parameters, execution);
taskService.start(taskId);
TaskEntity taskEntity = taskService.detail(taskId);
result = JsonUtils.fromJson(taskEntity.getResultJson(), DatabaseChangeResult.class);
Expand All @@ -120,7 +121,8 @@ protected DatabaseChangeResult start(Long taskId, TaskService taskService, Deleg
result = asyncTaskThread.getResult();
result.setRollbackPlanResult(rollbackPlanTaskResult);
result.setAutoModifyTimeout(this.autoModifyTimeout);
if (asyncTaskThread.isAbort()) {
if (asyncTaskThread.isAbort()
|| (result.getFailCount() > 0 && parameters.isMarkAsFailedWhenAnyErrorsHappened())) {
isFailure = true;
taskService.fail(taskId, asyncTaskThread.getProgressPercentage(), result);
} else if (asyncTaskThread.getStop()) {
Expand Down Expand Up @@ -186,9 +188,9 @@ protected void onProgressUpdate(Long taskId, TaskService taskService) {
}
}

private DatabaseChangeThread generateOdcAsyncTaskThread(Long taskId, DelegateExecution execution) {
private DatabaseChangeThread generateOdcAsyncTaskThread(Long taskId,
DatabaseChangeParameters parameters, DelegateExecution execution) {
Long creatorId = FlowTaskUtil.getTaskCreator(execution).getId();
DatabaseChangeParameters parameters = FlowTaskUtil.getAsyncParameter(execution);
ConnectionConfig connectionConfig = FlowTaskUtil.getConnectionConfig(execution);
modifyTimeoutIfTimeConsumingSqlExists(execution, parameters, connectionConfig.getDialectType(), creatorId);
connectionConfig.setQueryTimeoutSeconds((int) TimeUnit.MILLISECONDS.toSeconds(parameters.getTimeoutMillis()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class DatabaseChangeParameters implements Serializable, TaskParameters {
private List<String> rollbackSqlObjectIds;
private Long timeoutMillis = 172800000L;// 2d for default
private TaskErrorStrategy errorStrategy;
private boolean markAsFailedWhenAnyErrorsHappened;
private String delimiter = ";";
private Integer queryLimit = 1000;
private Integer riskLevelIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private void submitSubDatabaseChangeTask(Long parentFlowInstanceId, Long databas
return;
}
DatabaseChangeParameters taskParameters = new DatabaseChangeParameters();
taskParameters.setMarkAsFailedWhenAnyErrorsHappened(true);
taskParameters.setModifyTimeoutIfTimeConsumingSqlExists(false);
taskParameters.setErrorStrategy(errorStrategy.name());
StringBuilder sqlContent = new StringBuilder();
Expand Down