zhuangchong opened a new issue, #18731:
URL: https://github.com/apache/dolphinscheduler/issues/18731

   ### Search before asking
   
   - [x] I searched the existing issues and did not find an issue describing 
this behavior.
   
   ### What happened
   
   Switching an online workflow to another definition version marks the 
workflow definition as `OFFLINE`, but leaves its schedule `ONLINE` and its 
Quartz job registered.
   
   This differs from the normal workflow offline action, which immediately 
offlines the associated schedule and removes its Quartz job. With version 
switching, schedule cleanup is delayed until the next scheduled trigger detects 
that the workflow is offline.
   
   ### What you expected to happen
   
   Switching workflow definition versions should offline the associated 
schedule and remove its Quartz job immediately, just like the normal workflow 
offline action. It should not wait for the next scheduled trigger.
   
   ### How to reproduce
   
   1. Create a workflow with at least two definition versions.
   2. Publish the workflow and enable its schedule, with the next trigger 
sufficiently far in the future.
   3. Open the workflow version list and switch to a different version, or call 
the workflow version-switch API.
   4. Observe that the workflow is `OFFLINE`, while its schedule remains 
`ONLINE` and its Quartz job still exists.
   5. At the next scheduled trigger, the schedule task detects the offline 
workflow and cleans up the schedule.
   
   ### Root cause
   
   `WorkflowDefinitionServiceImpl.switchWorkflowDefinitionVersion` delegates to 
`ProcessServiceImpl.switchVersion`. The latter writes the target workflow 
version with `ReleaseState.OFFLINE`, but does not offline its schedule.
   
   By contrast, `WorkflowDefinitionServiceImpl.offlineWorkflowDefinition` calls 
`schedulerService.offlineSchedulerByWorkflowCode`, which updates the schedule 
state and removes its Quartz job.
   
   ### Suggested fix
   
   After switching the workflow version successfully, call the existing 
`offlineSchedulerByWorkflowCode` method from the API service. Reuse the 
existing behavior for workflows without schedules and for schedules that are 
already offline.
   
   ### Version
   
   Current `dev` branch, inspected at commit `751ed0352`.
   
   ### Are you willing to submit a PR?
   
   - [x] Yes, I am willing to submit a 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: 
[email protected]

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

Reply via email to