snuyanzin commented on code in PR #29399:
URL: https://github.com/apache/flink/pull/29399#discussion_r4200674737


##########
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandlerTest.java:
##########
@@ -427,4 +432,86 @@ public long getLastUpdateTime() {
                                 .collect(Collectors.toList()))
                 .containsExactly(0, 1);
     }
+
+    /**
+     * The handler must not throw when a subtask's attempts are pruned 
concurrently (by {@code
+     * SubtaskMetricStore.retainAttempts()}) between its {@code size()}/{@code 
containsKey()} checks
+     * and the {@code keySet().iterator().next()} read. See FLINK-36146.
+     */
+    @Test
+    void testGetBackPressureWhenAttemptsRemovedConcurrently() throws Exception 
{
+        MetricStore multipleAttemptsMetricStore = new MetricStore();
+        for (MetricDump metricDump : getMultipleAttemptsMetricDumps()) {
+            multipleAttemptsMetricStore.add(metricDump);
+        }
+
+        // Empty subtask 0's attempts in the window between the handler's 
check and its iteration.
+        SubtaskMetricStore subtask =
+                multipleAttemptsMetricStore
+                        .getTaskMetricStore(
+                                
TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE.toString(),
+                                TEST_JOB_VERTEX_ID.toString())
+                        .getAllSubtaskMetricStores()
+                        .get(0);
+        Field attemptsField = 
SubtaskMetricStore.class.getDeclaredField("attempts");
+        attemptsField.setAccessible(true);
+        @SuppressWarnings("unchecked")

Review Comment:
   done



##########
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandlerTest.java:
##########
@@ -427,4 +432,86 @@ public long getLastUpdateTime() {
                                 .collect(Collectors.toList()))
                 .containsExactly(0, 1);
     }
+
+    /**
+     * The handler must not throw when a subtask's attempts are pruned 
concurrently (by {@code
+     * SubtaskMetricStore.retainAttempts()}) between its {@code size()}/{@code 
containsKey()} checks
+     * and the {@code keySet().iterator().next()} read. See FLINK-36146.

Review Comment:
   done



-- 
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]

Reply via email to