spuru9 commented on code in PR #29008:
URL: https://github.com/apache/flink/pull/29008#discussion_r4496452308


##########
flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/history/AbstractHistoryServerHandlerTest.java:
##########
@@ -374,4 +376,59 @@ void testLazyModeLoadResource() throws Exception {
         assertThat(detailResponse.get().f1).contains(jobId.toString());
         assertThat(blockingArchiveStorage.exists("jobs/" + jobId + 
"/config.json")).isTrue();
     }
+
+    /**
+     * Two users open two jobs outside the cached window in {@code LAZY} mode. 
Viewing the second
+     * job must not cancel the first job's fetch that is still in flight.
+     */
+    @TestTemplate
+    void testLazyModeViewingAnotherJobDoesNotCancelInFlightFetch() throws 
Exception {
+        startServer(LAZY);
+
+        JobID newest = JobID.generate();
+        JobID first = JobID.generate();
+        JobID second = JobID.generate();
+        long now = System.currentTimeMillis();
+        long[] times = {now - 3000, now - 2000, now - 1000};
+        JobID[] ids = {first, second, newest};
+        for (int i = 0; i < ids.length; i++) {
+            org.apache.flink.core.fs.Path archive =
+                    createJobArchive(remoteArchiveRootPath.toFile(), ids[i], 
true);
+            assertThat(new 
File(archive.toUri()).setLastModified(times[i])).isTrue();
+        }
+
+        assertThat(HttpUtils.getFromHTTP(baseUrl + 
"/jobs/overview").f0).isEqualTo(200);
+
+        HistoryServerTestUtils.BlockingArchiveStorage<?> storage =
+                (HistoryServerTestUtils.BlockingArchiveStorage<?>) 
handler.archiveStorage;
+
+        AtomicReference<Tuple2<Integer, String>> firstResponse = new 
AtomicReference<>();
+        CompletableFuture<Void> firstFuture = requestAsync(first, 
firstResponse);
+        Thread.sleep(500);
+        assertThat(firstFuture.isDone()).isFalse();
+
+        // viewing another old job while the first fetch is still blocked
+        AtomicReference<Tuple2<Integer, String>> secondResponse = new 
AtomicReference<>();
+        CompletableFuture<Void> secondFuture = requestAsync(second, 
secondResponse);
+        Thread.sleep(500);

Review Comment:
   minor: Could we avoid the two sleeps here? Nothing guarantees the first 
fetch is blocked, or that the second request has hit markRecentlyViewed before 
the latch is released, so this can pass without the fix. I'd wait on the actual 
state instead, e.g. until the first job's meta info is DETAIL_PARSING and the 
second job's meta info exists, then release the latch.
   



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