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

   ## What is the purpose of the change
   
   
`MemoryManagerConcurrentModReleaseTest.testConcurrentModificationWhileReleasing`
 sometimes runs until the CI fork is killed (15 minutes without output).
   
   The test checks that `MemoryManager#release(Collection)` handles a list of 
memory segments that another thread changes while `release()` gives the 
segments back: a pass over the list that sees a change fails with 
`ConcurrentModificationException` and `release()` retries with a new pass. In 
the test, a second thread moved segments within the list without pause and was 
stopped only after `release()` finished. While it kept moving segments, every 
pass saw a change, so `release()` never finished and the second thread was 
never stopped. The thread dump in the JIRA ticket shows both threads busy in 
these loops for 19 minutes.
   
   ## Brief change log
   
     - The second thread stops after `release()` has started 10 passes over the 
list.
     - The list used by the test waits halfway through each of these 10 passes 
until the second thread has moved a segment since the pass started, so every 
one of them sees a change and is retried. Before any later pass it waits until 
the second thread has stopped, so the last pass and the `clear()` that 
`release()` calls afterwards never overlap with a move. No sleeps.
     - Removed the initial `Thread.sleep(500)`.
     - The test now also checks the number of passes (exactly 11), that the 
list is empty and that all memory was returned.
   
   The intention of the test does not change: `release()` is still tested 
against a real second thread that changes the list, and the retry now happens 
on every run. `MemoryManager` is unchanged.
   
   ## Verifying this change
   
   This change is already covered by existing tests: it changes only 
`MemoryManagerConcurrentModReleaseTest`.
   
     - Before/after on GitHub Actions, 100 runs each in the Flink CI container 
(JDK 17): https://github.com/robinrvm/flink/actions/runs/45949945670
       - master (560e4399): 0 of 100 hung, but the test took up to 20.2 s 
(median 4.1 s) for about 0.5 s of work.
       - with this change: 0 of 100 failed, max 0.25 s.
     - Locally, the changed test passed 2000 of 2000 runs. With the retry 
removed from `release()`, the test fails.
     - Reproducing the hang: without forcing it, it was reproduced once: in a 
local loop of the test's logic (same second-thread loop, with a watchdog), 1 of 
30 runs was still inside `release()` after 20 s (17.8 million passes) and 
returned right after the second thread was stopped. The unchanged test did not 
hang in 500 local runs and 100 GitHub runs. Forcing every pass to see a change 
reproduces it every time: `release()` made 397,570 passes in 10 s without 
returning, and returned 0.3 ms after the changes stopped. A thread dump of that 
forced run shows the same frames as the CI dump 
(`ConcurrentHashMap.computeIfPresent` ← `MemoryManager.java:343` ← 
`MemoryManager.java:327`).
   
   ## 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
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code 2.1.299 (Claude Opus 5.5)
   


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