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

   ## What is the purpose of the change
   
   Fixes the flaky `HistoryServerArchiveFetcherTest`, which intermittently 
fails in CI during JUnit teardown (seen on `testLazyFetchArchiveProactively`):
   
   ```
   org.junit.platform.commons.JUnitException: Failed to close extension context
   Caused by: java.io.IOException: Failed to delete temp directory 
/tmp/junit-....
     The following paths could not be deleted: <root>, jobs
       Suppressed: java.nio.file.DirectoryNotEmptyException: /tmp/junit-.../jobs
   ```
   
   Each test creates a `HistoryServerArchiveFetcher`, which owns two fixed 
thread pools that write archives into `localArchiveRootPath` (a `@TempDir`). 
The fetcher was never closed — `tearDown()` only closed the storage — so its 
executor threads could still be creating files under `jobs/` while JUnit was 
deleting the temp directory, causing the `DirectoryNotEmptyException`.
   
   ## Brief change log
   
   - Track the per-test `HistoryServerArchiveFetcher` in a field.
   - Close it in `@AfterEach` before closing the storage, so 
`HistoryServerArchiveFetcher#close()` (`ExecutorUtils.gracefulShutdown`) drains 
both thread pools before the `@TempDir` is removed. This also removes the same 
latent executor leak in the other test methods.
   
   Test-only change; no production code is touched.
   
   ## Verifying this change
   
   This change is a test-stability fix, verified by running the affected test 
in a loop on the exact commit that failed in CI (JDK 17):
   
   - `HistoryServerArchiveFetcherTest` (10 methods × 2 storage backends) passed 
**62 consecutive runs** with **0** temp-directory cleanup failures.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): **no**
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: **no**
     - The serializers: **no**
     - The runtime per-record code paths (performance sensitive): **no**
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: **no**
     - The S3 file system connector: **no**
   
   ## Documentation
   
     - Does this pull request introduce a new feature? **no**
     - If yes, how is the feature documented? **not applicable**
   
   ## AI usage disclosure
   
   - Claude Code
   


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