From 7c12e360f7f4a7efe4502373e0c823f82ae63b8f Mon Sep 17 00:00:00 2001 From: och5351 Date: Mon, 15 Jun 2026 00:02:05 +0900 Subject: [PATCH] [FLINK-39921][runtime/tests] Fix the flaky test case ExecutionTimeBasedSlowTaskDetectorTest due to unexepected ComponentMainThreadExecutor setting. Co-authored-by: Yuepeng Pan --- .../ExecutionTimeBasedSlowTaskDetectorTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/slowtaskdetector/ExecutionTimeBasedSlowTaskDetectorTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/slowtaskdetector/ExecutionTimeBasedSlowTaskDetectorTest.java index 5ec9baeb3ccd0..d01a095a66cf7 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/slowtaskdetector/ExecutionTimeBasedSlowTaskDetectorTest.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/slowtaskdetector/ExecutionTimeBasedSlowTaskDetectorTest.java @@ -22,10 +22,12 @@ import org.apache.flink.configuration.Configuration; import org.apache.flink.configuration.SlowTaskDetectorOptions; import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter; +import org.apache.flink.runtime.concurrent.NoMainThreadCheckComponentMainThreadExecutor; import org.apache.flink.runtime.executiongraph.ExecutionAttemptID; import org.apache.flink.runtime.executiongraph.ExecutionGraph; import org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils; import org.apache.flink.runtime.executiongraph.ExecutionVertex; +import org.apache.flink.runtime.executiongraph.utils.ExecutionUtils; import org.apache.flink.runtime.io.network.partition.ResultPartitionType; import org.apache.flink.runtime.jobgraph.DistributionPattern; import org.apache.flink.runtime.jobgraph.JobGraph; @@ -91,7 +93,7 @@ void testAllTasksInCreatedAndNoSlowTasks() throws Exception { final ExecutionGraph executionGraph = SchedulerTestingUtils.createScheduler( jobGraph, - ComponentMainThreadExecutorServiceAdapter.forMainThread(), + new NoMainThreadCheckComponentMainThreadExecutor(), EXECUTOR_RESOURCE.getExecutor()) .getExecutionGraph(); @@ -433,12 +435,15 @@ private ExecutionGraph createExecutionGraph(JobVertex... jobVertices) throws Exc final SchedulerBase scheduler = SchedulerTestingUtils.createScheduler( jobGraph, - ComponentMainThreadExecutorServiceAdapter.forMainThread(), + new NoMainThreadCheckComponentMainThreadExecutor(), EXECUTOR_RESOURCE.getExecutor()); final ExecutionGraph executionGraph = scheduler.getExecutionGraph(); scheduler.startScheduling(); + for (ExecutionVertex ev : executionGraph.getAllExecutionVertices()) { + ExecutionUtils.waitForTaskDeploymentDescriptorsCreation(ev); + } ExecutionGraphTestUtils.switchAllVerticesToRunning(executionGraph); return executionGraph; @@ -450,13 +455,16 @@ private ExecutionGraph createDynamicExecutionGraph(JobVertex... jobVertices) thr final SchedulerBase scheduler = new DefaultSchedulerBuilder( jobGraph, - ComponentMainThreadExecutorServiceAdapter.forMainThread(), + new NoMainThreadCheckComponentMainThreadExecutor(), EXECUTOR_RESOURCE.getExecutor()) .buildAdaptiveBatchJobScheduler(); final ExecutionGraph executionGraph = scheduler.getExecutionGraph(); scheduler.startScheduling(); + for (ExecutionVertex ev : executionGraph.getAllExecutionVertices()) { + ExecutionUtils.waitForTaskDeploymentDescriptorsCreation(ev); + } ExecutionGraphTestUtils.switchAllVerticesToRunning(executionGraph); return executionGraph;