You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "TimurRakhmatullin86 (via GitHub)" <gi...@apache.org> on 2026/09/25 03:51:28 UTC
[PR] Restore interrupted status in 9 InterruptedException catch blocks [cassandra]
TimurRakhmatullin86 opened a new pull request, #5212:
URL: https://github.com/apache/cassandra/pull/5212
## Summary
When catching `InterruptedException`, the JVM clears the thread's interrupt flag. If the catch block neither re-throws nor calls `Thread.currentThread().interrupt()`, upstream code relying on `Thread.interrupted()` or `isInterrupted()` will miss the signal. In a heavily threaded system like Cassandra, this can cause:
- **Delayed or failed shutdowns** — threads that poll `isInterrupted()` to exit their run loops never see the flag.
- **Silent cancellation loss** — operations that should be cancelled continue running.
- **Infinite loops** — a `while(true)` with a blocking `queue.take()` that swallows `InterruptedException` will spin indefinitely if the sentinel value is never enqueued.
This patch adds `Thread.currentThread().interrupt()` to **9 catch blocks** across the codebase that were swallowing the interrupt status:
| File | Method / Context | Impact |
|------|-----------------|--------|
| `AsyncStreamingInputPlus` | `close()` — `while(true)` loop draining a queue | Infinite spin risk if sentinel never enqueued |
| `PathUtils` | File deletion via external process | Callers checking `isInterrupted()` after receiving the wrapped `IOException` miss the interrupt |
| `ReconfigureCMS` | `repairPaxosForCMSTopologyChange()` | Interrupt lost on return from paxos repair |
| `NewGossiper` | `doShadowRound()` — multi-exception catch | `InterruptedException` silently consumed alongside `ExecutionException`/`TimeoutException` |
| `LocalLog` | `awaitTermination` during shutdown | Shutdown thread loses interrupt signal |
| `CompactionManager` | `stopCompaction()` — `awaitTermination` | Calling thread cannot detect the interrupt |
| `AccordResult` | `awaitAndGet()` | Failure stored but thread flag cleared |
| `AutoRepair` | Repair await in retry loop | Retry loop continues despite interrupt |
| `HintsDispatcher` | `await()` — returns `INTERRUPTED` enum | Return value signals interrupt, but thread-level flag is cleared |
## Approach
Each fix is minimal: a single `Thread.currentThread().interrupt()` call added immediately inside the catch block, before any existing logging, return, or fallback logic. No behavioral changes beyond restoring the flag that the JVM cleared.
This follows the standard Java concurrency best practice documented in Brian Goetz's *Java Concurrency in Practice* (Section 7.1.3) and the [`InterruptedException` Javadoc](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/InterruptedException.html).
## Test plan
- [x] Each change is a single-line addition of `Thread.currentThread().interrupt()` — no logic changes
- [ ] Existing unit and integration tests continue to pass
- [ ] Grep confirms no remaining `catch (InterruptedException` blocks that silently swallow the flag without re-throwing
🤖 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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] Restore interrupted status in 9 InterruptedException catch blocks [cassandra]
Posted by "TimurRakhmatullin86 (via GitHub)" <gi...@apache.org>.
TimurRakhmatullin86 closed pull request #5212: Restore interrupted status in 9 InterruptedException catch blocks
URL: https://github.com/apache/cassandra/pull/5212
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] Restore interrupted status in 9 InterruptedException catch blocks [cassandra]
Posted by "bbotella (via GitHub)" <gi...@apache.org>.
bbotella commented on PR #5212:
URL: https://github.com/apache/cassandra/pull/5212#issuecomment-5886771195
Please add a Jira ticket for this to be reviewed.
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org