biaoma-ty opened a new issue, #14846:
URL: https://github.com/apache/dolphinscheduler/issues/14846

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   When attempting to copy values from one `TaskInstance` object to another 
using the `copyTaskInstance` method, if the target `TaskInstance` object has 
null values, these null values overwrite valid data in the source object. As a 
result, a `NullPointerException` is thrown, specifically at the point where the 
`workerAddress` is used, since it was inadvertently set to null.
   
   
   ### What you expected to happen
   
   ```java
   [ERROR] 2023-09-02 17:03:03.654 +0800 
org.apache.dolphinscheduler.server.master.processor.queue.TaskExecuteRunnable:[64]
 - [WorkflowInstance-73][TaskInstance-89] - Handle task event error, this event 
will be removed, event: TaskEvent(taskInstanceId=89, workerAddress=null, 
state=TaskExecutionStatus{code=1, desc='running'}, startTime=Sat Sep 02 
06:21:38 CST 2023, endTime=null, executePath=null, 
logPath=/Users/biaoma/Develop/Src/dolphinscheduler/logs/20230902/10723137779649/10/73/89.log,
 processId=0, appIds=null, event=RUNNING, varPool=null, cacheTaskInstanceId=0, 
processInstanceId=73)
   org.apache.dolphinscheduler.server.master.event.TaskEventHandleError: Handle 
task running event error, update taskInstance to db failed
        at 
org.apache.dolphinscheduler.server.master.event.TaskRunningEventHandler.handleTaskEvent(TaskRunningEventHandler.java:98)
        at 
org.apache.dolphinscheduler.server.master.processor.queue.TaskExecuteRunnable.run(TaskExecuteRunnable.java:56)
        at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
   Caused by: java.lang.NullPointerException: null
        at 
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:889)
        at com.google.common.cache.LocalCache.get(LocalCache.java:3965)
        at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3989)
        at 
com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4950)
        at 
org.apache.dolphinscheduler.extract.base.client.JdkDynamicRpcClientProxyFactory.getProxyClient(JdkDynamicRpcClientProxyFactory.java:60)
        at 
org.apache.dolphinscheduler.extract.base.client.SingletonJdkDynamicRpcClientProxyFactory.getProxyClient(SingletonJdkDynamicRpcClientProxyFactory.java:29)
        at 
org.apache.dolphinscheduler.server.master.event.TaskRunningEventHandler.sendAckToWorker(TaskRunningEventHandler.java:114)
        at 
org.apache.dolphinscheduler.server.master.event.TaskRunningEventHandler.handleTaskEvent(TaskRunningEventHandler.java:92)
        ... 6 common frames omitted
   [INFO] 2023-09-02 17:03:03.654 +0800 
org.apache.dolphinscheduler.server.master.processor.queue.TaskExecuteRunnable:[55]
 - [WorkflowInstance-73][TaskInstance-89] - Handle task event begin: 
TaskEvent(taskInstanceId=89, workerAddress=null, 
state=TaskExecutionStatus{code=6, desc='failure'}, startTime=Sat Sep 02 
06:21:38 CST 2023, endTime=Sat Sep 02 06:28:38 CST 2023, 
executePath=/tmp/dolphinscheduler/exec/process/default/10683251927488/10723137779649_10/73/89,
 
logPath=/Users/biaoma/Develop/Src/dolphinscheduler/logs/20230902/10723137779649/10/73/89.log,
 processId=0, appIds=null, event=RESULT, varPool=[], cacheTaskInstanceId=0, 
processInstanceId=73)
   [ERROR] 2023-09-02 17:03:03.658 +0800 
org.apache.dolphinscheduler.server.master.processor.queue.TaskExecuteRunnable:[64]
 - [WorkflowInstance-73][TaskInstance-89] - Handle task event error, this event 
will be removed, event: TaskEvent(taskInstanceId=89, workerAddress=null, 
state=TaskExecutionStatus{code=6, desc='failure'}, startTime=Sat Sep 02 
06:21:38 CST 2023, endTime=Sat Sep 02 06:28:38 CST 2023, 
executePath=/tmp/dolphinscheduler/exec/process/default/10683251927488/10723137779649_10/73/89,
 
logPath=/Users/biaoma/Develop/Src/dolphinscheduler/logs/20230902/10723137779649/10/73/89.log,
 processId=0, appIds=null, event=RESULT, varPool=[], cacheTaskInstanceId=0, 
processInstanceId=73)
   org.apache.dolphinscheduler.server.master.event.TaskEventHandleError: Handle 
task result event error, save taskInstance to db error
        at 
org.apache.dolphinscheduler.server.master.event.TaskResultEventHandler.handleTaskEvent(TaskResultEventHandler.java:105)
        at 
org.apache.dolphinscheduler.server.master.processor.queue.TaskExecuteRunnable.run(TaskExecuteRunnable.java:56)
        at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
   Caused by: java.lang.NullPointerException: null
        at 
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:889)
        at com.google.common.cache.LocalCache.get(LocalCache.java:3965)
        at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3989)
        at 
com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4950)
        at 
org.apache.dolphinscheduler.extract.base.client.JdkDynamicRpcClientProxyFactory.getProxyClient(JdkDynamicRpcClientProxyFactory.java:60)
        at 
org.apache.dolphinscheduler.extract.base.client.SingletonJdkDynamicRpcClientProxyFactory.getProxyClient(SingletonJdkDynamicRpcClientProxyFactory.java:29)
        at 
org.apache.dolphinscheduler.server.master.event.TaskResultEventHandler.sendAckToWorker(TaskResultEventHandler.java:120)
        at 
org.apache.dolphinscheduler.server.master.event.TaskResultEventHandler.handleTaskEvent(TaskResultEventHandler.java:102)
        ... 6 common frames omitted
   ```
   
   ### How to reproduce
   
   1. Create a new `TaskInstance` object (e.g., `oldTaskInstance`) without 
setting any of its properties (they will default to null).
   2. Call the `copyTaskInstance` method with a valid `TaskInstance` (with set 
properties) as the source and the newly created `TaskInstance` as the target.
   3. Observe that valid values in the source object have been replaced with 
null values, leading to errors in subsequent operations.
   
   
   ### Anything else
   
   The issue seems to happen every time the described scenario is replicated. 
The error logs have been provided above. A simple fix might be to check for 
null values in the target `TaskInstance` before assigning its properties.
   
   
   ### Version
   
   dev
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to