Skip to content

fix: Handle channel removal during request processing to prevent Kafka errors#3132

Open
adhnanjeff wants to merge 1 commit intoAutoMQ:mainfrom
adhnanjeff:bugfix/kafka-channel-removed-selector
Open

fix: Handle channel removal during request processing to prevent Kafka errors#3132
adhnanjeff wants to merge 1 commit intoAutoMQ:mainfrom
adhnanjeff:bugfix/kafka-channel-removed-selector

Conversation

@adhnanjeff
Copy link
Copy Markdown

… completed receive" #2094

AutoMQ Channel Removal Bug Fix - Test Results

Bug Fixed

Issue: IllegalStateException: Channel xxxx removed from selector before processing completed receive

Changes Made

  1. processCompletedReceives() - Replaced IllegalStateException with warning log
  2. sendResponse() - Added try-catch with proper resource cleanup
  3. processCompletedSends() - Added exception handling for unmute operations
  4. processNewResponses() - Enhanced exception handling

Test Results

Source Code Verification

  • All fixes are properly implemented in SocketServer.scala
  • Warning logs replace IllegalStateException throws
  • Exception handling added for channel operations

AutoMQ Running Successfully

  • Container started and running normally
  • Processing messages without crashes
  • No processor thread failures observed

Connection Tests Completed

  • Rapid connection/disconnection tests executed
  • No IllegalStateException crashes detected
  • Server continues processing other connections

Before Fix (Expected Behavior)

ERROR Exception while processing request from 10.0.0.94:9092-10.0.0.96:37376-2493
java.lang.IllegalStateException: Channel xxx removed from selector before processing completed receive

After Fix (Actual Behavior)

WARN Channel xxx removed from selector before processing completed receive

Conclusion

Fix Successfully Implemented

  • Processor threads no longer crash on abrupt disconnections
  • Server maintains stability during high connection churn
  • Graceful handling of channel state transitions
  • Proper resource cleanup prevents memory leaks

The fix ensures AutoMQ can handle production workloads with frequent client connections and disconnections without experiencing processor thread crashes.

More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.

Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

… completed receive" AutoMQ#2094

## AutoMQ Channel Removal Bug Fix - Test Results

### Bug Fixed
**Issue**: `IllegalStateException: Channel xxxx removed from selector before processing completed receive`

### Changes Made
1. **processCompletedReceives()** - Replaced IllegalStateException with warning log
2. **sendResponse()** - Added try-catch with proper resource cleanup
3. **processCompletedSends()** - Added exception handling for unmute operations
4. **processNewResponses()** - Enhanced exception handling

### Test Results

✅ **Source Code Verification**
- All fixes are properly implemented in SocketServer.scala
- Warning logs replace IllegalStateException throws
- Exception handling added for channel operations

✅ **AutoMQ Running Successfully**
- Container started and running normally
- Processing messages without crashes
- No processor thread failures observed

✅ **Connection Tests Completed**
- Rapid connection/disconnection tests executed
- No IllegalStateException crashes detected
- Server continues processing other connections

### Before Fix (Expected Behavior)
```
ERROR Exception while processing request from 10.0.0.94:9092-10.0.0.96:37376-2493
java.lang.IllegalStateException: Channel xxx removed from selector before processing completed receive
```

### After Fix (Actual Behavior)
```
WARN Channel xxx removed from selector before processing completed receive
```

### Conclusion
✅ **Fix Successfully Implemented**
- Processor threads no longer crash on abrupt disconnections
- Server maintains stability during high connection churn
- Graceful handling of channel state transitions
- Proper resource cleanup prevents memory leaks

The fix ensures AutoMQ can handle production workloads with frequent client connections and disconnections without experiencing processor thread crashes.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 1, 2026

CLA assistant check
All committers have signed the CLA.

@adhnanjeff adhnanjeff changed the title [BUG] ERROR log "Channel xxxx removed from selector before processing… fix: Handle channel removal during request processing to prevent Kafka errors Jan 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has merge conflicts, please update it with the latest from trunk (or appropriate release branch)

If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.

@github-actions github-actions bot added the Stale label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants