[BUG] Disabling the last scaling policy leaves the dynamic monitoring task running
Current behavior
ScaleService.executeScaling() cancels DynamicScalingTask only inside its non-null active-policy branch. When there are no active policies it simply returns, leaving a previously registered dynamic task running.
Location and trigger
- ScaleService.java:66–87
ScalePolicyServiceImpl.applyPolicy()updates the cache and callsexecuteScaling()after a policy update commits.
- Enable policy
3with a positive monitor interval and no other active policy. - Disable that policy.
getActivePolicy()now returns null; the scheduled task remains registered and continues invokingmetricsMonitor.monitorMetrics().
Validation and impact
P2 / Medium; confirmed, high confidence. A standalone probe compiled the current ScaleService and TaskSchedulerManager, initialized a real ScalePolicyCache, enabled policy 3, then set its status to 0 and ran executeScaling() again:
TASKS_ENABLED=1
TASKS_ALL_DISABLED=1
The unchanged scheduled task still owns the monitoring callback. An isolated reviewer independently confirmed the update path. Monitoring/Prometheus traffic and observer callbacks continue after disabling scaling. This issue does not claim a successful replica update while the separate uninitialized-scale-spec defect remains present.
Suggested fix
Cancel the dynamic task on the no-active-policy path. Make the transition from active dynamic policy to zero active policies explicitly stop monitoring, including when all policies are disabled after a database commit.
Related existing work
No matching historical/live scaling-disabled issue found. #5521 is the feature umbrella; #6624 concerns partial cached policy fields. This is a policy-state transition bug, distinct from scheduler cleanup at application shutdown.
Reviewed revision
Apache ShenYu 2.7.2-SNAPSHOT, master@66d7d954ca37d651a5ad916f988a8081157a7ab4. This repository review excludes unit-test and CI issue categories.
I'd like to work on this issue. I plan to add a regression test for disabling the last active dynamic policy, cancel its monitoring task when no active policy remains, and verify repeated cancellation and policy switching.
I'd like to work on this issue. I plan to add a regression test for disabling the last active dynamic policy, cancel its monitoring task when no active policy remains, and verify repeated cancellation and policy switching.
just comment /assign then bot will assign this issue to you