TimurRakhmatullin86 opened a new pull request, #29295: URL: https://github.com/apache/flink/pull/29295
## What is the purpose of the change When catching `InterruptedException`, the interrupt flag on the current thread is cleared by the JVM. Code that catches this exception must restore the flag by calling `Thread.currentThread().interrupt()` before re-throwing, wrapping, or returning. Otherwise, upstream code (callers, thread pools, shutdown hooks) cannot detect that an interrupt occurred, leading to subtle concurrency bugs such as threads failing to shut down gracefully. This PR audits and fixes all `InterruptedException` catch blocks across `flink-core` and `flink-runtime` where the interrupt status was silently swallowed. ## Brief change log Add `Thread.currentThread().interrupt()` calls in catch blocks that handle `InterruptedException` across the following modules: **flink-core** - `FutureUtils` — split multi-catch to restore interrupt status separately from `ExecutionException` **flink-runtime — checkpoint / filemerging** - `BlockingPhysicalFilePool` **flink-runtime — cluster entrypoint** - `ClusterEntrypoint` **flink-runtime — file cache** - `FileCache` **flink-runtime — I/O subsystem** - `AsynchronousBlockReader` - `AsynchronousBlockWriter` - `AsynchronousFileIOChannel` - `IOManagerAsync` (2 locations) **flink-runtime — network partition** - `BufferWritingResultPartition` - `SortMergeResultPartition` - `DiskTierConsumerAgent` (2 locations) - `MemoryTierConsumerAgent` (2 locations) **flink-runtime — iterative processing** - `BlockingBackChannel` - `Broker` (2 locations) - `SerializedUpdateBuffer` (5 locations) **flink-runtime — network utilities** - `ConnectionUtils` (3 locations) **flink-runtime — operators** - `BatchTask` - `TempBarrier` - `ComponentClosingUtils` (3 locations) - `HashPartition` - `MutableHashTable` (3 locations) - `ExternalSorter` - `LargeRecordHandler` - `ReaderIterator` (2 locations) **flink-runtime — security** - `DefaultDelegationTokenManager` **flink-runtime — source coordinator** - `SourceCoordinatorContext` **flink-runtime — streaming** - `CollectResultFetcher` (2 locations) - `StreamIterationTail` ## Verifying this change This change restores interrupt status propagation and does not alter control flow. Each fix adds a single `Thread.currentThread().interrupt()` call before the existing re-throw, wrap, or return statement. Existing unit and integration tests continue to pass without modification. ## 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): yes (interrupt status restoration adds a single method call in the exceptional path only — no impact on the hot path) - Anything that affects deployment or recovery: no - The (broadcasting) state machine: no 🤖 Generated with [Claude Code](https://claude.com/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]
