You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "RocMarshal (via GitHub)" <gi...@apache.org> on 2025/09/11 01:44:04 UTC

[PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

RocMarshal opened a new pull request, #26976:
URL: https://github.com/apache/flink/pull/26976

   
   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   Fix the bug that The local files of the HistoryServer may risk never being deleted.
   
   
   ## Brief change log
   
   In the HistoryServer constructor, first clear all files in the historyserver.web.tmpdirdirectory before proceeding with the original initialization logic. This ensures that the local files marked for cleanup—based on HistoryServerArchiveFetcher#cachedArchivesPerRefreshDirectory—are free from leaks.
   
   
   ## Verifying this change
   
   This change is already covered by existing tests.
   
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #26976:
URL: https://github.com/apache/flink/pull/26976#issuecomment-3287237590

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26976:
URL: https://github.com/apache/flink/pull/26976#discussion_r2343569518


##########
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServer.java:
##########
@@ -197,15 +197,7 @@ public HistoryServer(
         webRefreshIntervalMillis =
                 config.get(HistoryServerOptions.HISTORY_SERVER_WEB_REFRESH_INTERVAL).toMillis();
 
-        String webDirectory = config.get(HistoryServerOptions.HISTORY_SERVER_WEB_DIR);
-        if (webDirectory == null) {
-            webDirectory =
-                    System.getProperty("java.io.tmpdir")
-                            + File.separator
-                            + "flink-web-history-"
-                            + UUID.randomUUID();
-        }
-        webDir = new File(webDirectory);
+        webDir = prepareWebDir(config);

Review Comment:
   Please could you add a unit test for this change



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26976:
URL: https://github.com/apache/flink/pull/26976#discussion_r2378173611


##########
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServer.java:
##########
@@ -257,6 +249,35 @@ public HistoryServer(
                         HistoryServer.this::stop, HistoryServer.class.getSimpleName(), LOG);
     }
 
+    private File prepareWebDir(Configuration config) throws IOException {
+        final File webDir;
+        String webDirectory = config.get(HistoryServerOptions.HISTORY_SERVER_WEB_DIR);
+        if (webDirectory == null) {
+            webDirectory =
+                    System.getProperty("java.io.tmpdir")
+                            + File.separator
+                            + "flink-web-history-"
+                            + UUID.randomUUID();
+        }
+        webDir = new File(webDirectory);
+        LOG.info("Reset the web directory {}", webDir);

Review Comment:
   nit: I suggest saying `Clear `or 'empty' rather than `Reset` - also the method name would be more self explanatory if it was` clearWebDir ` I, think. But it is up to you



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "WeiZhong94 (via GitHub)" <gi...@apache.org>.
WeiZhong94 commented on PR #26976:
URL: https://github.com/apache/flink/pull/26976#issuecomment-3338140049

   LGTM. The CI failure originates from the Python section and is unrelated to this PR. Merging.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #26976:
URL: https://github.com/apache/flink/pull/26976#issuecomment-3341157791

   Thanks @WeiZhong94 @davidradl for the review.
   The BP PRs were ready in   
   - https://github.com/apache/flink/pull/27053
   - https://github.com/apache/flink/pull/27051
   - https://github.com/apache/flink/pull/27052


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #26976:
URL: https://github.com/apache/flink/pull/26976#issuecomment-3332777923

   Thanks @davidradl for the review 👍 


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "WeiZhong94 (via GitHub)" <gi...@apache.org>.
WeiZhong94 merged PR #26976:
URL: https://github.com/apache/flink/pull/26976


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #26976:
URL: https://github.com/apache/flink/pull/26976#discussion_r2347717542


##########
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServer.java:
##########
@@ -197,15 +197,7 @@ public HistoryServer(
         webRefreshIntervalMillis =
                 config.get(HistoryServerOptions.HISTORY_SERVER_WEB_REFRESH_INTERVAL).toMillis();
 
-        String webDirectory = config.get(HistoryServerOptions.HISTORY_SERVER_WEB_DIR);
-        if (webDirectory == null) {
-            webDirectory =
-                    System.getProperty("java.io.tmpdir")
-                            + File.separator
-                            + "flink-web-history-"
-                            + UUID.randomUUID();
-        }
-        webDir = new File(webDirectory);
+        webDir = prepareWebDir(config);

Review Comment:
   Of course, I have added a unit test for this change.
   
   Thank you for your comments. Could you @davidradl help take a look ?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #26976:
URL: https://github.com/apache/flink/pull/26976#issuecomment-3277087496

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7be287df626f6c402aedccc57c34e2946d89bbe8",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7be287df626f6c402aedccc57c34e2946d89bbe8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7be287df626f6c402aedccc57c34e2946d89bbe8 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-38344][runtime-web] Fix the bug that The local files of the HistoryServer may risk never being deleted. [flink]

Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26976:
URL: https://github.com/apache/flink/pull/26976#discussion_r2378162776


##########
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServer.java:
##########
@@ -257,6 +249,35 @@ public HistoryServer(
                         HistoryServer.this::stop, HistoryServer.class.getSimpleName(), LOG);
     }
 
+    private File prepareWebDir(Configuration config) throws IOException {
+        final File webDir;
+        String webDirectory = config.get(HistoryServerOptions.HISTORY_SERVER_WEB_DIR);
+        if (webDirectory == null) {
+            webDirectory =
+                    System.getProperty("java.io.tmpdir")
+                            + File.separator
+                            + "flink-web-history-"
+                            + UUID.randomUUID();
+        }
+        webDir = new File(webDirectory);

Review Comment:
   nit : can we not have  `final File webDir = new File(webDirectory);` here?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org