scylladb / python-driver

ScyllaDB Python Driver, originally DataStax Python Driver for Apache Cassandra
https://python-driver.docs.scylladb.com
Apache License 2.0
70 stars 42 forks source link

Connecting to Unix domain socket fails #278

Closed margdoc closed 8 months ago

margdoc commented 9 months ago

When trying to connect to unix domain socket, python driver throws following error:

Traceback (most recent call last):
  File "/home/margdoc/Workspace/scylla/maintenance_mode_testing.py", line 5, in <module>
    s = c.connect()
        ^^^^^^^^^^^
  File "cassandra/cluster.py", line 1750, in cassandra.cluster.Cluster.connect
  File "cassandra/cluster.py", line 1776, in cassandra.cluster.Cluster.connect
  File "cassandra/cluster.py", line 1763, in cassandra.cluster.Cluster.connect
  File "cassandra/cluster.py", line 3581, in cassandra.cluster.ControlConnection.connect
  File "cassandra/cluster.py", line 3642, in cassandra.cluster.ControlConnection._reconnect_internal
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'test_socket': IndexError('string index out of range')})

In function: https://github.com/scylladb/python-driver/blob/679ad2490b7bfb440cbda122712380acff925dde/cassandra/connection.py#L926-L961 Line:

log.debug('Connection %s %s:%s -> %s:%s', id(self), local_addr[0], local_addr[1], sockaddr[0], sockaddr[1])

Reproducer:

Socket created in a terminal:

nc -lkU test_socket 

Code that uses python driver:

from cassandra.cluster import Cluster
from cassandra.connection import UnixSocketEndPoint

c = Cluster([UnixSocketEndPoint("test_socket")])
s = c.connect()
kbr-scylla commented 9 months ago

Some more context

cc @Lorak-mmk @avelanarius

avelanarius commented 9 months ago

I will work on fixing this problem. We discussed with @Lorak-mmk that after that fix is merged, we will release the next version of Python Driver (not waiting for any more changes like merging upstream or any inflight PRs).