Code review comment: `parallelism2` is the task number for before rescale, and `2 * parallelism2` is the task number for after rescale. Ideally, we should wait for all tasks after rescale to become running.   That's exactly what FLINK-34336 fix.  > Why does it increase the hang possibility?  When the rescale with cooldown=30s, the rescale action will be executed after 30s. When the `waitForRunningTasks` is called, the job is still running with old parallelism, so the `waitForRunningTasks` can be done.   When we disable the scaling cooldown, the rescale may happen immediately. When it happens, the job will be running with `2 * parallelism2`, so `waitForRunningTasks` with old parallelism2 will be hang forever.  > And why did we merge it into master?  IIUC, we should wait for all tasks after rescale to become running.  But these 2 callers wait for all tasks before rescale. These 2 wait are unexpected, so I think it's a separate bug regardless of we disable/enable cooldown.   It means we should wait for  all tasks after rescale even if we enable cooldown=30s. That's why I create a separate JIRA (FLINK-34336) to follow it.  Why do I merge it into master?   1. I think `Disable the scaling cooldown to speed up the test` and FLINK-34336 are separate 2. I guess `Disable the scaling cooldown to speed up the test` may be cause AutoRescalingITCase hang, so I prepare https://github.com/apache/flink/pull/24248 in advanced. It's easy to be merged to fix the hang.   > Why do we merge it then now?  1. `Disable the scaling cooldown to speed up the test` is a minor improvement for test instead of bugfix. So it's not necessary for 1.19 IIUC. 2. 1.19 will be released soon, I'm afraid to affect this release. So I merge it in master(1.20) first. 3. After FLINK-34226 is fixed, this minor improvement doesn't have any negative impact(I didn't notice any), so merging it may be make sense. WDYT?

Code under review:
public void testCheckpointRescalingNonPartitionedStateCausesException() throws Exception {
        final int parallelism = totalSlots / 2;
        final int parallelism2 = totalSlots;
        final int maxParallelism = 13;

        ClusterClient<?> client = cluster.getClusterClient();

        try {
            JobGraph jobGraph =
                    createJobGraphWithOperatorState(
                            parallelism, maxParallelism, OperatorCheckpointMethod.NON_PARTITIONED);
            
            StateSourceBase.canFinishLatch = new CountDownLatch(1);

            final JobID jobID = jobGraph.getJobID();

            client.submitJob(jobGraph).get();

            
            waitForAllTaskRunning(cluster.getMiniCluster(), jobGraph.getJobID(), false);
            
            StateSourceBase.workStartedLatch.await();

            waitForNewCheckpoint(jobID, cluster.getMiniCluster());

            JobResourceRequirements.Builder builder = JobResourceRequirements.newBuilder();
            for (JobVertex vertex : jobGraph.getVertices()) {
                builder.setParallelismForJobVertex(vertex.getID(), parallelism2, parallelism2);
            }

            restClusterClient.updateJobResourceRequirements(jobID, builder.build()).join();

            waitForRunningTasks(restClusterClient, jobID, 2 * parallelism2);
            waitForAvailableSlots(restClusterClient, totalSlots - parallelism2);

            StateSourceBase.canFinishLatch.countDown();

            client.requestJobResult(jobID).get();
        } catch (JobExecutionException exception) {
            if (!(exception.getCause() instanceof IllegalStateException)) {
                throw exception;
            }
        }
    }

Line commented on: waitForRunningTasks(restClusterClient, jobID, 2 * parallelism2);

Revised code:
public void testCheckpointRescalingNonPartitionedStateCausesException() throws Exception {
        final int parallelism = totalSlots / 2;
        final int parallelism2 = totalSlots;
        final int maxParallelism = 13;

        ClusterClient<?> client = cluster.getClusterClient();

        try {
            JobGraph jobGraph =
                    createJobGraphWithOperatorState(
                            parallelism, maxParallelism, OperatorCheckpointMethod.NON_PARTITIONED);
            
            StateSourceBase.canFinishLatch = new CountDownLatch(1);

            final JobID jobID = jobGraph.getJobID();

            client.submitJob(jobGraph).get();

            
            waitForAllTaskRunning(cluster.getMiniCluster(), jobGraph.getJobID(), false);
            
            StateSourceBase.workStartedLatch.await();

            waitForNewCheckpoint(jobID, cluster.getMiniCluster());

            JobResourceRequirements.Builder builder = JobResourceRequirements.newBuilder();
            for (JobVertex vertex : jobGraph.getVertices()) {
                builder.setParallelismForJobVertex(vertex.getID(), parallelism2, parallelism2);
            }

            restClusterClient.updateJobResourceRequirements(jobID, builder.build()).join();

            waitForRunningTasks(restClusterClient, jobID, 2 * parallelism2);
            waitForAvailableSlots(restClusterClient, totalSlots - parallelism2);

            StateSourceBase.canFinishLatch.countDown();

            client.requestJobResult(jobID).get();
        } catch (JobExecutionException exception) {
            if (!(exception.getCause() instanceof IllegalStateException)) {
                throw exception;
            }
        }
    }