You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "njnu-seafish (via GitHub)" <gi...@apache.org> on 2025/12/02 12:25:07 UTC
[PR] [Fix-17758] [Master]Add logic to handle tasks that fail during initialization. [dolphinscheduler]
njnu-seafish opened a new pull request, #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759
<!--Thanks very much for contributing to Apache DolphinScheduler, we are happy that you want to help us improve DolphinScheduler! -->
## Purpose of the pull request
close #17758
## Brief change log
Add logic to handle tasks that fail during initialization.
## Verify this pull request
<!--*(Please pick either of the following options)*-->
This pull request is code cleanup without any test coverage.
*(or)*
This pull request is already covered by existing tests, such as *(please describe tests)*.
(or)
This change added tests and can be verified as follows:
<!--*(example:)*
- *Added dolphinscheduler-dao tests for end-to-end.*
- *Added CronUtilsTest to verify the change.*
- *Manually verified the change by testing locally.* -->
(or)
## Pull Request Notice
[Pull Request Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
If your pull request contains incompatible change, you should also add it to `docs/docs/en/guide/upgrade/incompatible.md`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2587180401
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/lifecycle/event/TaskFatalLifecycleEvent.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event;
+
+import org.apache.dolphinscheduler.server.master.engine.ILifecycleEventType;
+import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.AbstractTaskLifecycleEvent;
+import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.TaskLifecycleEventType;
+import org.apache.dolphinscheduler.server.master.engine.task.runnable.ITaskExecutionRunnable;
+
+import java.util.Date;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+
+@Data
+@Builder
+@AllArgsConstructor
+public class TaskFatalLifecycleEvent extends AbstractTaskLifecycleEvent {
+
+ private final ITaskExecutionRunnable taskExecutionRunnable;
Review Comment:
## Missing Override annotation
This method overrides [AbstractTaskLifecycleEvent.getTaskExecutionRunnable](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5592)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2608995675
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/ITaskStateAction.java:
##########
@@ -89,7 +91,15 @@ void onRetryEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable,
*/
void onDispatchEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable,
final ITaskExecutionRunnable taskExecutionRunnable,
- final TaskDispatchLifecycleEvent taskDispatchEvent);
+ final TaskDispatchLifecycleEvent taskDispatchEvent) throws TaskFatalException;
+
+ /**
+ * Perform the necessary actions when the task in a certain state receive a {@link TaskFatalLifecycleEvent}.
+ * <p> This method is called when the task encounters an unrecoverable error (e.g., initialization failure).
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2608993849
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/AbstractTaskStateAction.java:
##########
@@ -99,6 +100,29 @@ protected void releaseTaskInstanceResourcesIfNeeded(final ITaskExecutionRunnable
}
}
+ @Override
+ public void onFatalEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable,
+ final ITaskExecutionRunnable taskExecutionRunnable,
+ final TaskFatalLifecycleEvent taskFatalEvent) {
+ releaseTaskInstanceResourcesIfNeeded(taskExecutionRunnable);
+
+ final TaskInstance taskInstance = taskExecutionRunnable.getTaskInstance();
+ taskInstance.setState(TaskExecutionStatus.FAILURE);
+ taskInstance.setEndTime(taskFatalEvent.getEndTime());
+ taskInstanceDao.updateById(taskInstance);
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3609756437
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate failed**
Failed conditions
 [14.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list) (required ≥ 60%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3629950425
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [87.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3641125040
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [85.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list)
 [5.7% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3604734393
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate failed**
Failed conditions
 [35.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list) (required ≥ 60%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2609658379
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java:
##########
@@ -109,7 +110,12 @@ public void onDispatchEvent(final IWorkflowExecutionRunnable workflowExecutionRu
taskInstance.getDelayTime(),
remainTimeMills);
}
- taskExecutionRunnable.initializeTaskExecutionContext();
+ try {
+ taskExecutionRunnable.initializeTaskExecutionContext();
+ } catch (Exception ex) {
+ log.error("Current taskInstance: {} initializeTaskExecutionContext fail", taskInstance.getName(), ex);
+ throw new TaskFatalException(taskInstance.getName() + " initializeTaskExecutionContext fail");
+ }
Review Comment:
> taskExecutionRunnable.initializeTaskExecutionContext();
ok,catch exception and publish TaskFatalLifecycleEvent in doFireSingleWorkflowEventBus
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2591207574
##########
dolphinscheduler-master/src/test/resources/it/start/workflow_with_one_condition_task_with_one_fake_predecessor_fatal.yaml:
##########
@@ -0,0 +1,123 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# A(fatal-failed) -> B(success) -> D(success)
+project:
+ name: MasterIntegrationTest
+ code: 1
+ description: This is a fake project
+ userId: 1
+ userName: admin
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2024-08-12 00:00:00
+
+workflows:
+ - name: workflow_with_one_condition_task_with_one_fake_predecessor_fatal
+ code: 1
+ version: 1
+ projectCode: 1
+ description: This is a fake workflow with one condition task which has one predecessor fatal
+ releaseState: ONLINE
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2024-08-12 00:00:00
+ userId: 1
+ executionType: PARALLEL
+
+tasks:
+ - name: A
+ code: 1
+ version: 1
+ projectCode: 1
+ userId: 1
+ taskType: LogicFakeTask
+ taskParams: '{"localParams":null,"varPool":[],"shellScript":"echo success"}'
+ workerGroup: default
+ environmentCode : 144873539254368
Review Comment:
Inconsistent spacing around colon. The key `environmentCode` should be followed by a colon without a space before it, consistent with other YAML files in this directory. Change `environmentCode :` to `environmentCode:`.
```suggestion
environmentCode: 144873539254368
```
##########
dolphinscheduler-master/src/test/resources/it/start/workflow_with_one_condition_task_with_one_fake_predecessor_fatal.yaml:
##########
@@ -0,0 +1,123 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# A(fatal-failed) -> B(success) -> D(success)
Review Comment:
The comment incorrectly describes the workflow structure. Based on the taskRelations, the structure is: A(fatal-failed) -> B(Condition) -> C(success) or D(failed). The comment should be updated to: `# A(fatal-failed) -> B(Condition) -> C(success) or D(failed)`.
```suggestion
# A(fatal-failed) -> B(Condition) -> C(success) or D(failed)
```
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/AbstractTaskStateAction.java:
##########
@@ -99,6 +100,29 @@ protected void releaseTaskInstanceResourcesIfNeeded(final ITaskExecutionRunnable
}
}
+ @Override
+ public void onFatalEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable,
+ final ITaskExecutionRunnable taskExecutionRunnable,
+ final TaskFatalLifecycleEvent taskFatalEvent) {
+ releaseTaskInstanceResourcesIfNeeded(taskExecutionRunnable);
+
+ final TaskInstance taskInstance = taskExecutionRunnable.getTaskInstance();
+ taskInstance.setState(TaskExecutionStatus.FAILURE);
+ taskInstance.setEndTime(taskFatalEvent.getEndTime());
+ taskInstanceDao.updateById(taskInstance);
Review Comment:
[nitpick] For consistency with other event handlers in this class (e.g., `onFailedEvent`, `onPausedEvent`, `onKilledEvent`), consider extracting the persistence logic into a private helper method like `persistentTaskInstanceFatalEventToDB`. This improves code maintainability and follows the established pattern in this class.
##########
dolphinscheduler-master/src/test/resources/it/start/workflow_with_one_forbidden_condition_task_with_one_fake_predecessor_fatal.yaml:
##########
@@ -0,0 +1,125 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# A(failed) -> B(Condition)(forbidden) -> C(success)
Review Comment:
The comment says "A(failed)" but based on the filename and test description, this should be "A(fatal)". The comment should be updated to: `# A(fatal) -> B(Condition)(forbidden) -> C(success)`.
```suggestion
# A(fatal) -> B(Condition)(forbidden) -> C(success)
```
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/lifecycle/event/TaskFatalLifecycleEvent.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event;
+
+import org.apache.dolphinscheduler.server.master.engine.ILifecycleEventType;
+import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.AbstractTaskLifecycleEvent;
+import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.TaskLifecycleEventType;
+import org.apache.dolphinscheduler.server.master.engine.task.runnable.ITaskExecutionRunnable;
+
+import java.util.Date;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+
+@Data
+@Builder
+@AllArgsConstructor
+public class TaskFatalLifecycleEvent extends AbstractTaskLifecycleEvent {
+
+ private final ITaskExecutionRunnable taskExecutionRunnable;
Review Comment:
This method overrides [AbstractTaskLifecycleEvent.getTaskExecutionRunnable](1); it is advisable to add an Override annotation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2608980875
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/lifecycle/TaskLifecycleEventType.java:
##########
@@ -29,6 +29,10 @@ public enum TaskLifecycleEventType implements ILifecycleEventType {
* Dispatch the task instance to target.
*/
DISPATCH,
+ /**
+ * Severe and unrecoverable errors, such as initialization failure.
Review Comment:
>
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3629954677
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [89.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3615126187
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [93.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3641123443
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17759&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [85.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list)
 [5.7% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3609750587
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate failed**
Failed conditions
 [14.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list) (required ≥ 60%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3606756466
> Should fire a `TaskFailedLifecycleEvent` when task initialize failed.
yes, add logic to handle TaskFatalLifecycleEvent
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2598250029
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java:
##########
@@ -109,7 +111,17 @@ public void onDispatchEvent(final IWorkflowExecutionRunnable workflowExecutionRu
taskInstance.getDelayTime(),
remainTimeMills);
}
- taskExecutionRunnable.initializeTaskExecutionContext();
+ try {
+ taskExecutionRunnable.initializeTaskExecutionContext();
+ } catch (Exception ex) {
+ log.error("Current taskInstance: {} initializeTaskExecutionContext error", taskInstance.getName(), ex);
+ final TaskFatalLifecycleEvent taskFatalEvent = TaskFatalLifecycleEvent.builder()
+ .taskExecutionRunnable(taskExecutionRunnable)
+ .endTime(new Date())
+ .build();
+ taskExecutionRunnable.getWorkflowEventBus().publish(taskFatalEvent);
+ return;
+ }
Review Comment:
> You need to create a `TaskFatalException`, and throw `TaskFatalException` here and handle `TaskFatalException` at `WorkflowEventBusFireWorker`.
ok. first throw TaskFatalException then publish TaskFatalLifecycleEvent
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2608866047
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/AbstractTaskStateAction.java:
##########
@@ -99,6 +100,29 @@ protected void releaseTaskInstanceResourcesIfNeeded(final ITaskExecutionRunnable
}
}
+ @Override
+ public void onFatalEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable,
+ final ITaskExecutionRunnable taskExecutionRunnable,
+ final TaskFatalLifecycleEvent taskFatalEvent) {
+ releaseTaskInstanceResourcesIfNeeded(taskExecutionRunnable);
+
+ final TaskInstance taskInstance = taskExecutionRunnable.getTaskInstance();
+ taskInstance.setState(TaskExecutionStatus.FAILURE);
+ taskInstance.setEndTime(taskFatalEvent.getEndTime());
+ taskInstanceDao.updateById(taskInstance);
Review Comment:
```suggestion
persistentTaskInstanceFatalEventToDB(taskExecutionRunnable, taskFatalEvent)
```
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java:
##########
@@ -109,7 +110,12 @@ public void onDispatchEvent(final IWorkflowExecutionRunnable workflowExecutionRu
taskInstance.getDelayTime(),
remainTimeMills);
}
- taskExecutionRunnable.initializeTaskExecutionContext();
+ try {
+ taskExecutionRunnable.initializeTaskExecutionContext();
+ } catch (Exception ex) {
+ log.error("Current taskInstance: {} initializeTaskExecutionContext fail", taskInstance.getName(), ex);
+ throw new TaskFatalException(taskInstance.getName() + " initializeTaskExecutionContext fail");
+ }
Review Comment:
```suggestion
taskExecutionRunnable.initializeTaskExecutionContext();
```
It's better to throw `TaskFatalException` in `TaskExecutionContextFactory#createTaskExecutionContext` method. Not all exception should be transformed to `TaskFatalException`.
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/lifecycle/TaskLifecycleEventType.java:
##########
@@ -29,6 +29,10 @@ public enum TaskLifecycleEventType implements ILifecycleEventType {
* Dispatch the task instance to target.
*/
DISPATCH,
+ /**
+ * Severe and unrecoverable errors, such as initialization failure.
Review Comment:
```suggestion
* Task instance encounters catastrophic failure, it will enter a failed state.
```
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/WorkflowEventBusFireWorker.java:
##########
@@ -128,6 +132,19 @@ private void doFireSingleWorkflowEventBus(final IWorkflowExecutionRunnable workf
ThreadUtils.sleep(5_000);
return;
}
+ // the task encounters an unrecoverable error (e.g., initialization failure).
+ if (ExceptionUtils.isTaskFatalException(ex)) {
+ log.warn("Task fatal exception occurred during event handling: {}", lifecycleEvent, ex);
+ if (lifecycleEvent instanceof TaskDispatchLifecycleEvent) {
Review Comment:
```suggestion
if (lifecycleEvent instanceof AbstractTaskLifecycleEvent) {
```
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/ITaskStateAction.java:
##########
@@ -89,7 +91,15 @@ void onRetryEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable,
*/
void onDispatchEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable,
final ITaskExecutionRunnable taskExecutionRunnable,
- final TaskDispatchLifecycleEvent taskDispatchEvent);
+ final TaskDispatchLifecycleEvent taskDispatchEvent) throws TaskFatalException;
+
+ /**
+ * Perform the necessary actions when the task in a certain state receive a {@link TaskFatalLifecycleEvent}.
+ * <p> This method is called when the task encounters an unrecoverable error (e.g., initialization failure).
Review Comment:
```suggestion
* <p> This method is called when the task encounters catastrophic failure (e.g., initialization failure).
```
We will still retry the task instance if config retry policy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3639844888
We need to use more direct titles to indicate the problems addressed by the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2609659028
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/WorkflowEventBusFireWorker.java:
##########
@@ -128,6 +132,19 @@ private void doFireSingleWorkflowEventBus(final IWorkflowExecutionRunnable workf
ThreadUtils.sleep(5_000);
return;
}
+ // the task encounters an unrecoverable error (e.g., initialization failure).
+ if (ExceptionUtils.isTaskFatalException(ex)) {
+ log.warn("Task fatal exception occurred during event handling: {}", lifecycleEvent, ex);
+ if (lifecycleEvent instanceof TaskDispatchLifecycleEvent) {
Review Comment:
>
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Mark task as failed if TaskExecutionContext initialization fails [dolphinscheduler]
Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS merged PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#discussion_r2591194297
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java:
##########
@@ -109,7 +111,17 @@ public void onDispatchEvent(final IWorkflowExecutionRunnable workflowExecutionRu
taskInstance.getDelayTime(),
remainTimeMills);
}
- taskExecutionRunnable.initializeTaskExecutionContext();
+ try {
+ taskExecutionRunnable.initializeTaskExecutionContext();
+ } catch (Exception ex) {
+ log.error("Current taskInstance: {} initializeTaskExecutionContext error", taskInstance.getName(), ex);
+ final TaskFatalLifecycleEvent taskFatalEvent = TaskFatalLifecycleEvent.builder()
+ .taskExecutionRunnable(taskExecutionRunnable)
+ .endTime(new Date())
+ .build();
+ taskExecutionRunnable.getWorkflowEventBus().publish(taskFatalEvent);
+ return;
+ }
Review Comment:
You need to create a `TaskFatalException`, and throw `TaskFatalException` here and handle `TaskFatalException` at `WorkflowEventBusFireWorker`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix-17758][Master] Add logic to handle tasks that fail during initialization. [dolphinscheduler]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17759:
URL: https://github.com/apache/dolphinscheduler/pull/17759#issuecomment-3604728916
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759) **Quality Gate failed**
Failed conditions
 [35.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17759&metric=new_coverage&view=list) (required ≥ 60%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17759)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org