naveencodet commented on PR #30096: URL: https://github.com/apache/flink/pull/30096#issuecomment-7272974747
@MartijnVisser - There are **two independent races** in the rescale timeline tests, and both depend on how much CPU the test JVM gets. - **Race 1, cooldown:** the 100 ms executing cooldown can end before the test's cancel or failover arrives. This hits `testRescaleTerminatedByJobCancelled` and `testRecordNonTerminatedRescaleMergingWithNewRecoverableFailureTriggerCause`. - **Race 2, initial schedule:** the job can start at parallelism 1 or 2 when the second TaskManager registers late. A third `NEW_RESOURCE_AVAILABLE` rescale then appears. This is the FLINK-40789 mechanism. - The 50→100 ms submission-stabilization bump only matters on the Azure agents. On the GitHub agents I checked, which were healthy, I could not reproduce either failure in the pipeline. - **No shared-baseline change is proposed for now.** The failures show up only under a very small timing margin. > [!IMPORTANT] > **Proposal: raise the executing cooldown from 100 ms → 200 ms, the same approach as the 50 → 100 ms stabilization bump.** > > - **These are new tests.** The rescale timeline ITCases were added on 2026-03-23 (FLINK-38342), so they have a short history and the 100 ms margin was never tuned against slow agents. > - In the container stress this **halved the failures** (11/22 → 4/15 failed iterations, see section 5). > - It **reduces the flake but is not a full fix.** It removes some of the cooldown race (Race 1) and does nothing for the initial-schedule race (Race 2). <details> <summary><b>1. What fails</b></summary> | Test | Symptom | Cause | |---|---|---| | `RescaleTimelineITCase#testRecordRescaleForNewAvailableResource` (FLINK-40789) | 3 rescales recorded (2→4→6) instead of 2 | Race 2, initial schedule | | `RescaleTimelineHistoryEnabledITCase#testRescaleTerminatedByJobCancelled` | Update rescale closed as `NO_RESOURCES_OR_PARALLELISMS_CHANGE` instead of `JOB_CANCELED` | Race 1, cooldown | | `RescaleTimelineITCase#testRecordNonTerminatedRescaleMergingWithNewRecoverableFailureTriggerCause` | 3 history entries instead of the merged 2 | Race 1, cooldown | Failing upstream run for the cancel test: [apache/flink run 43225531533](https://github.com/apache/flink/actions/runs/43225531533/job/131232773215). </details> <details> <summary><b>2. Root cause</b></summary> **Race 1, cooldown.** The cooldown clock starts when `Executing` is constructed. If the 100 ms cooldown ends first, `Idling` closes the update rescale as `NO_RESOURCES_OR_PARALLELISMS_CHANGE`. `goToCanceling` only stamps `JOB_CANCELED` when `!rescaleTimeline.isIdling()`. In the merge test the failover then starts a separate rescale instead of merging, which gives 3 entries. **Race 2, initial schedule.** The waiting-for-resources transition manager has no cooldown and uses the submission stabilization timeout (50 ms in tests, `maxTriggerDelay` zero). `Stabilized.onTrigger` proceeds with sufficient resources, and only the minimum parallelism is needed. A second TaskManager that registers late gives an initial parallelism of 1 or 2. A `NEW_RESOURCE_AVAILABLE` rescale is then recorded, adding a third history entry. Not confirmed: the Azure run for FLINK-40789 could not be opened, so its exact cause on Azure is inferred from the container reproduction. </details> <details> <summary><b>3. Test vs production configuration</b></summary> | Option | Production default | Shared test value | |---|---|---| | Executing cooldown | 30 s | 100 ms | | Executing resource stabilization | 60 s | 50 ms | | Submission resource stabilization | 10 s | 50 ms | | Submission resource wait | 5 min | 2 s | Minimal values are deliberate in the tests. Per-test clusters in `RescaleTimelineHistoryEnabledITCase`: JobFinished 60 s/60 s; JobCancelled, JobFailed and ResourcesNotEnough use the shared 100 ms/50 ms; NoResources 10 s/50 ms; ResourceRequirementsUpdated 60 s/60 s. </details> <details> <summary><b>4. Pipeline runs on the fork </b></summary> | Time | Run | Branch / workflow | Jobs | Job result | |---|---|---|---|---| | 02:22 | [46097704570](https://github.com/naveencodet/flink/actions/runs/46097704570) | `FLINK-40789-rescale-diagnostics`, Diag RescaleTimelineITCase | 1 | success (about 12 min) | | 02:39 | [46099131269](https://github.com/naveencodet/flink/actions/runs/46099131269) | same, second run | 1 | success (about 11 min) | | 02:58 | [46100609041](https://github.com/naveencodet/flink/actions/runs/46100609041) | same, Diag core stage x10 | compile + 10 core runs | all success (25–37 min each) | | 04:13 | [46106561765](https://github.com/naveencodet/flink/actions/runs/46106561765) | `diag-cancel-test-timing`, cancel core x10 | compile + 10 core runs | all 10 failed after about 1 min (setup problem, not the test) | | 04:34 | [46108201503](https://github.com/naveencodet/flink/actions/runs/46108201503) | same, rerun | compile + 10 core runs | all success (27–44 min each) | | 06:36 | [46117372935](https://github.com/naveencodet/flink/actions/runs/46117372935) | `diag-merge-test-x50` | 10 jobs × 5 reps | all success (5–7 min each) | - "Success" is the job status. I have not read the per-run test outcomes for every run above. - Healthy GitHub runners, summed over these runs: the FLINK-40789 test passed about 80 executions, the merge test failed once in about 180, and the cancel test never failed. - Median time from RUNNING to terminate or cancel was about **37 ms**. Of 100 merge-test executions, 14 took 90 ms or more, and 3 at 101–102 ms still passed, because the scheduler handles the event later than the test's call. The cooldown boundary is not sharp. - Runner hardware was mixed, 4 vCPU = 2 cores × 2 threads: Azure D4ads_v5/v6/v7 (EPYC 7763/9V74/9V45) and AWS KVM Xeon 6975P-C and Xeon Platinum 8573C. - In the merge ×50 run, sampled load was at most 2.43 on 4 vCPU, with at least 12 GB memory and 84 GB disk free. The core-stage sampler never produced data, so there is no resource data for those jobs. </details> <details> <summary><b>5. Reproduction under CPU starvation (container, 2 CPUs)</b></summary> Podman, `maven:3.8.8-eclipse-temurin-17` (JDK 17.0.9), CPU hogs plus a niced java wrapper, tests looped with `surefire:test`. Both races reproduce. **Cooldown sweep** (no wait for slots; failed iterations): | Cooldown | Failed iterations | Merge test | Cancel test | |---|---|---|---| | 100 ms (current) | 11 / 22 | 8 / 44 | 4 / 22 | | **200 ms (proposed)** | **4 / 15** | **2 / 30** | **2 / 15** | | 300 ms | 3 / 10 | 3 / 20 | 0 / 10 | | 500 ms | 2 / 10 | 1 / 20 | 1 / 10 | | 1000 ms | 1 / 10 | 0 / 20 | 1 / 10 | | 2000 ms | 1 / 10 | 0 / 20 | 1 / 10 | - At 200 ms the 4 failures were: 2 cooldown race (merge, 141 ms and 245 ms) and 2 initial parallelism 2 (cancel, 73 ms and 112 ms). - All 7 failures at 300 ms and above had an initial parallelism below 4. A longer cooldown cannot fix Race 2. **Waiting for 4 registered slots before submitting:** | Variant | Failed iterations | Notes | |---|---|---| | wait + 100 ms | 6 / 15 (merge 6/30, cancel 0/15) | 3 of 6 failures still had initial parallelism 2 | | wait + 1000 ms | **0 / 15** | | Slots registered at the resource manager do not guarantee that the job's slot pool already has them, so waiting alone is not enough. Caveat: samples are small (10–22 iterations per row), so neighbouring rows are within noise. </details> <details> <summary><b>6. What we tried</b></summary> - Submission stabilization 50→100 ms (branch `FLINK-40789-rescale-timeline-itcase`): helps the Azure agents only. - Per-test long cooldown (60 s/60 s) for the cancel test: passes on an idle machine (6 tests), not verified under stress. - Wait for slots in `startCluster`: reduces Race 2 but does not remove it. - Doubling the cooldown to 200 ms: halves the failures in the container stress, does not remove them. - Host-based stress on a Mac: abandoned, because heavy load starved Maven and the machine. - Resource sampler in CI container jobs: never produced data. </details> <details> -- 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]
