rickchengx commented on code in PR #15883:
URL: 
https://github.com/apache/dolphinscheduler/pull/15883#discussion_r1574043768


##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/TriggerRelationServiceImpl.java:
##########
@@ -45,29 +51,44 @@ public void saveTriggerToDb(ApiTriggerType type, Long 
triggerCode, Integer jobId
         triggerRelation.setUpdateTime(new Date());
         triggerRelationMapper.upsert(triggerRelation);
     }
+
     @Override
-    public TriggerRelation queryByTypeAndJobId(ApiTriggerType apiTriggerType, 
int jobId) {
+    public List<TriggerRelation> queryByTypeAndJobId(ApiTriggerType 
apiTriggerType, int jobId) {
         return 
triggerRelationMapper.queryByTypeAndJobId(apiTriggerType.getCode(), jobId);
     }
 
     @Override
     public int saveCommandTrigger(Integer commandId, Integer 
processInstanceId) {
-        TriggerRelation exist = queryByTypeAndJobId(ApiTriggerType.PROCESS, 
processInstanceId);
-        if (exist == null) {
+        List<TriggerRelation> existTriggers = 
queryByTypeAndJobId(ApiTriggerType.PROCESS, processInstanceId);
+        if (CollectionUtils.isEmpty(existTriggers)) {
             return 0;
         }
-        saveTriggerToDb(ApiTriggerType.COMMAND, exist.getTriggerCode(), 
commandId);
-        return 1;
+        existTriggers.forEach(triggerRelation -> 
saveTriggerToDb(ApiTriggerType.COMMAND,

Review Comment:
   If returning more than 1 result is a situation that should not occur, are 
there any potential problems if they are still stored into db?



-- 
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