-
Notifications
You must be signed in to change notification settings - Fork 4.1k
CASSANDRA-21191: [CEP-59] Implementation of In-Band Connection Draining (Graceful Disconnect) #4953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AshenScribe
wants to merge
6
commits into
apache:trunk
Choose a base branch
from
AshenScribe:feature/cep-59/metrics
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35e6cf1
cep 59
AshenScribe 635137a
reformated SimpleClient.java
3ee100e
removed Lifecycle way of Draining
0694e84
added client metrics tests
a325bad
removed ambuguity from functions names and a race condition
e0adab2
changed Protocol Version of GRACEFUL_DISCONNECT from V5 to V4 and
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
doc/modules/cassandra/pages/managing/operating/graceful_disconnect.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| = Graceful Disconnect — In-Band Connection Draining for Cassandra Node Shutdown | ||
|
|
||
| == Vocabulary | ||
|
|
||
| in-band:: same connection | ||
| In-flight requests:: requests that have been sent but not yet completed | ||
|
|
||
| == Introduction | ||
|
|
||
| When a Cassandra node has to be taken offline client drivers have no reliable, in-band signal that the node is going away. | ||
|
|
||
| * Drivers keep sending requests to a shutting-down node until they hit a socket close or timeout. | ||
| * In-flight requests are abandoned, producing `ReadTimeoutException` errors on the client side. | ||
| * Retry storms emerge as clients simultaneously rediscover the topology. | ||
|
|
||
| == Solution | ||
|
|
||
| Introduce an in-band signal — `GRACEFUL_DISCONNECT` — so that the server can notify clients (that have subscribed) connection before closing it. This gives drivers time to: | ||
|
|
||
| . Stop sending new requests on that connection/node. | ||
| . Let all in-flight requests complete. | ||
| . Close that socket connection (this notifies server that there are no pending queries on client side). | ||
| . Try reconnecting with exponential backoff. | ||
|
|
||
| == New Configurations Introduced | ||
|
|
||
| `graceful_disconnect_enabled`:: A configuration that enables the server to perform graceful disconnect. | ||
| `graceful_disconnect_grace_period`:: A configuration that forces shutdown of any active driver connection to the node after the grace period expires. | ||
|
|
||
| [cols="1,1,3,1", options="header"] | ||
| |=== | ||
| | Parameter | Type | Description | Default | ||
| | `graceful_disconnect_enabled` | Boolean | A configuration that enables server to perform graceful disconnect. | false | ||
| | `graceful_disconnect_grace_period` | Duration (ms) | A configuration that determines after how much time to force close a socket connection, if there is any pending connection from driver side. | 5s | ||
| |=== | ||
|
|
||
| == Client Compatibility & Upgrade Strategy | ||
|
|
||
| === Legacy Drivers — No Change Required | ||
|
|
||
| Drivers that do not support graceful disconnect are not affected by any value of `graceful_disconnect_enabled` or `graceful_disconnect_grace_period`. | ||
|
|
||
| === Required Driver Versions | ||
|
|
||
| To benefit from graceful draining, a compatible driver must be used. | ||
|
|
||
| [cols="1,1", options="header"] | ||
| |=== | ||
| | Driver | Status | ||
| | Java | https://issues.apache.org/jira/browse/CASSJAVA-124[In progress] | ||
| | Python | https://issues.apache.org/jira/browse/CASSPYTHON-16[In progress] | ||
| | Node.js | https://issues.apache.org/jira/browse/CASSNODEJS-5[In progress] | ||
| | Go | https://issues.apache.org/jira/browse/CASSGO-117[In progress] | ||
| | C++ | https://issues.apache.org/jira/browse/CASSCPP-7[In progress] | ||
| |=== | ||
|
|
||
| === Mixed-Fleet Rollout | ||
|
|
||
| During a rolling upgrade where some nodes support the feature and others do not: | ||
|
|
||
| * Nodes *with* `graceful_disconnect_enabled: true` advertise the capability in `SUPPORTED` and drivers subscribe. | ||
| * Nodes *without* the feature omit the key from `SUPPORTED`. Compatible drivers silently fall back to the legacy TCP teardown path for those nodes. | ||
|
|
||
| No special coordination is needed. Drivers handle both peers transparently within the same session. | ||
|
|
||
| == Operational Visibility | ||
|
|
||
| === Metrics | ||
|
|
||
| [cols="1,3", options="header"] | ||
| |=== | ||
| | Metric | Description | ||
| | `ConnectionsDraining` | Current count of connections in the Draining state (subscribed and awaiting in-flight completion). Should rise at drain start and fall to zero before shutdown completes. | ||
| | `ForcedDisconnects` | Cumulative count of connections force-closed after `graceful_disconnect_grace_period` expired without the driver closing cleanly. Persistent non-zero values here indicate driver-side issues or an undersized grace period. | ||
| |=== | ||
|
|
||
| == Failure Modes & Edge Cases | ||
|
|
||
| === What if the driver does not support `GRACEFUL_DISCONNECT`? | ||
|
|
||
| If the driver never sent `REGISTER` for this event type (legacy driver, or a compatible driver connected to a legacy node), the server applies *standard TCP teardown* — the same behavior as before this feature existed. There is no error, no retry storm specific to this feature, and no action required from operators. | ||
|
|
||
| This is the designed fallback and not an error condition. | ||
|
|
||
| === What will happen if two different driver, one supporting graceful disconnect while other not, are talking to a node supporting graceful disconnect? | ||
|
|
||
| Driver supporting graceful disconnect will disconnect gracefully, while the one not supporting graceful disconnect will behave as a legacy driver. | ||
|
|
||
| === What if the server crashes instead of draining cleanly? | ||
|
|
||
| `GRACEFUL_DISCONNECT` is *not* a crash-safety mechanism. If the JVM is killed with `SIGKILL`, the node loses power, or an OOM kill occurs, no `GRACEFUL_DISCONNECT` event is emitted. Drivers fall back to socket-close detection and gossip `DOWN` events — the current behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the default configuration itself?