shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[BUG] Disabling the last scaling policy leaves the dynamic monitoring task running

Open Aias00 opened this issue 1 month ago • 2 comments

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 calls executeScaling() after a policy update commits.
  1. Enable policy 3 with a positive monitor interval and no other active policy.
  2. Disable that policy.
  3. getActivePolicy() now returns null; the scheduled task remains registered and continues invoking metricsMonitor.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.

Aias00 avatar Oct 17 '26 05:10 Aias00

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.

Neymar-10-JR avatar Oct 17 '26 15:10 Neymar-10-JR

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

Aias00 avatar Oct 17 '26 16:10 Aias00