[
https://issues.apache.org/jira/browse/CASSPYTHON-16?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18071178#comment-18071178
]
Rishabh Saraswat commented on CASSPYTHON-16:
--------------------------------------------
Testing Script
{code:python}
import threadingfrom cassandra.cluster import Clusterprint("=== Test 1:
GRACEFUL_DISCONNECT advertised in SUPPORTED ===")
cluster = Cluster(['127.0.0.1'])
session = cluster.connect()
control_conn = cluster.control_connection._connection
print("supports_graceful_disconnect:",
control_conn.supports_graceful_disconnect)
assert control_conn.supports_graceful_disconnect, "FAILED: could not update to
support GRACEFUL_DISCONNECT"
print("PASSED")print("\n=== Test 2: Query executes successfully ===")
rows = session.execute("SELECT release_version FROM system.local")
for row in rows:
print("Cassandra version:", row.release_version)
print("PASSED")print("\n=== Test 3: GRACEFUL_DISCONNECT received on drain ===")
received_event = threading.Event()original_handle =
control_conn._handle_graceful_disconnect
def patched_handle():
print("GRACEFUL_DISCONNECT received!")
received_event.set()
original_handle()
control_conn._handle_graceful_disconnect = patched_handleprint("Now run
'nodetool drain' on the server...")
print("Waiting 30 seconds for event...")
if received_event.wait(timeout=30):
print("PASSED: GRACEFUL_DISCONNECT received")
else:
print("FAILED: GRACEFUL_DISCONNECT not received within 30
seconds")cluster.shutdown()
{code}
output
=== Test 1: GRACEFUL_DISCONNECT advertised in SUPPORTED ===
supports_graceful_disconnect: True
PASSED
=== Test 2: Query executes successfully ===
Cassandra version: 5.1-SNAPSHOT
PASSED
=== Test 3: GRACEFUL_DISCONNECT received on drain ===
Now run 'nodetool drain' on the server...
Waiting 30 seconds for event...
GRACEFUL_DISCONNECT received!
PASSED: GRACEFUL_DISCONNECT received
host found: 127.0.0.1:9042
> CEP-59: Add GRACEFUL_DISCONNECT support to Python driver
> --------------------------------------------------------
>
> Key: CASSPYTHON-16
> URL: https://issues.apache.org/jira/browse/CASSPYTHON-16
> Project: Apache Cassandra Python driver
> Issue Type: New Feature
> Reporter: Rishabh Saraswat
> Assignee: Rishabh Saraswat
> Priority: Normal
>
> See [CEP-59
> |https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=406619103]
> See [Server side |https://issues.apache.org/jira/browse/CASSANDRA-21191]
> Adds GRACEFUL_DISCONNECT support to the Python driver. The driver now detects
> server-side graceful disconnect support and subscribes to the event on all
> connections, allowing it to react gracefully when a node is shutting down.
> Flow:
> 1. Driver sends OPTIONS to server
> 2. If SUPPORTED response contains GRACEFUL_DISCONNECT: ["true"], driver
> adds GRACEFUL_DISCONNECT to event types before sending REGISTER
> 3. REGISTER is sent to server subscribing to GRACEFUL_DISCONNECT event.
> 4. Upon receiving GRACEFUL_DISCONNECT event on a connection, driver marks
> that node as down in the load balancing policy so new requests are
> routed to other healthy nodes
> 5. In-flight requests on the draining connection complete normally
> 6. Driver closes the connection once all in-flight requests are done
> Since the driver already maintains connections to all nodes, no reconnection
> is needed — requests are simply routed to already-connected healthy nodes.
> NOTE: Completion of this sub-task marks the final delivery of the GSoC 2026
> project (Ecosystem Integration & Graceful Draining).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]