Shanzita opened a new pull request, #4851:
URL: https://github.com/apache/cassandra/pull/4851
Found and fixed several bugs while testing the Java driver (CASSJAVA-124)
against this branch.
### Fixes
1. **EVENT_DISPATCHER AttributeKey lookup returns null**: `StorageService`
defined its own `AttributeKey.valueOf("EVTDISP")` instead of using
`Dispatcher.EVENT_DISPATCHER`. Since these are different object instances,
the dispatcher lookup in `gracefulDisconnect()` always returned null,
meaning the GRACEFUL_DISCONNECT event was never actually dispatched to
clients. Fixed by using `Dispatcher.EVENT_DISPATCHER` directly and making
it
public.
2. **Metrics double-decrement**: When the timeout fires, `runOnceAction`
called `decrementConnectionsDraining(remaining)` for all remaining
channels.
But the individual channel close listeners also call
`decrementConnectionsDraining()` when those channels eventually close,
causing the counter to go negative. Fixed by only tracking forced
disconnects in `runOnceAction` and letting close listeners handle all
decrements.
3. **Metrics race condition**: `incrementConnectionsDraining()` was called
after registering the close listener. If a channel closed synchronously
during `forEach`, the decrement would fire before the increment. Fixed by
moving the increment before the listener registration.
4. **Missing negative value validation**:
`setGracefulDisconnectGracePeriod()` didn't reject negative values via JMX.
5. **Misleading error message**: `setGracefulDisconnectMaxDrain()` error
message referenced `graceful_disconnect_enabled` even though the check runs
regardless.
6. **SimpleClient blocks on drain**: `handleGracefulDisconnect()` called
`lastWriteFuture.awaitUninterruptibly()` which blocks the Netty event loop
thread, then immediately called `close()` without waiting for in-flight
responses. Fixed by using `addListener()` for non-blocking close after the
write completes.
### Testing
- End-to-end tested with the Java driver: 200 queries during nodetool
drain,
0 errors
- Updated `GracefulDisconnectTest` to use `Dispatcher.EVENT_DISPATCHER`
JIRA:
[CASSANDRA-21191](https://issues.apache.org/jira/browse/CASSANDRA-21191)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]