apache / cassandra-gocql-driver

GoCQL Driver for Apache Cassandra®
https://cassandra.apache.org/
Apache License 2.0
2.57k stars 616 forks source link

Cassandra version 5: unsupported protocol error #1750

Open testisnullus opened 4 months ago

testisnullus commented 4 months ago

What version of Cassandra are you using?

5

What version of Gocql are you using?

v1.6.0

What version of Go are you using?

go1.21.6 linux/amd64

What did you do?

Trying to establish a session with the Cassandra v5 cluster (inside the Docker container) using native protocol v5. I saw that the version 5 protocol was added already, but it seems it is not working properly for some reason. I've debugged the connection process and found that the error happened during the readHeader() function execution. So, the process of connection according to logs looks like this:

stream: 1
framer: &{5 16 <nil> 9 <nil> [] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [] map[]}
p[byte]: [133 0 0 0 0 0 0 0 0]
p[:1]: [133]
version 5

stream: 64
framer: &{5 16 <nil> 9 <nil> [] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [] map[]}
p[byte]: [133 0 0 1 6 0 0 0 102]
p[:1]: [133]
version 5

stream: 128
framer: &{5 16 <nil> 9 <nil> [] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [] map[]}
p[byte]: [114 0 0 64 2 0 0 0 0]
p[:1]: [114]
version 114
_error here_

I've compared the connection process using 5 version with 3 and 4 versions of the protocol. It seems pretty similar, except the one thing. When we use the 5 version the first byte always changes from 133 to 114. Now, I am reading the native protocol 5 specification to understand what changes should be made to fix the issue. Will be glad to receive any suggestions regarding it.

Code snippet:

    cluster := gocql.NewCluster("172.17.0.2")
    cluster.Consistency = gocql.Quorum
    cluster.ProtoVersion = 5
    cluster.ConnectTimeout = time.Second * 10
    session, err := cluster.CreateSession()
    if err != nil {
        log.Println(err)
        return
    }
    defer session.Close()

What did you expect to see?

Successfully established connection

What did you see instead?

Error from the gocql:

2024/05/13 14:58:01 gocql: unable setup control conn 172.17.0.2:9042: gocql: unsupported protocol response version: 114
2024/05/13 14:58:01 gocql: unable to create session: unable to connect to initial hosts: gocql: unsupported protocol response version: 114

Cassandra logs:

ERROR [epollEventLoopGroup-5-5] 2024-05-13 11:58:01,959 NoSpamLogger.java:110 - 14ded18b invalid, unrecoverable CRC mismatch detected in frame header. Read 1920, Computed 15624576
WARN  [epollEventLoopGroup-5-5] 2024-05-13 11:58:01,960 NoSpamLogger.java:107 - Protocol exception with client networking: 14ded18b invalid, unrecoverable CRC mismatch detected in frame header. Read 1920, Computed 15624576

If you are having connectivity related issues please share the following additional information

Describe your Cassandra cluster

please provide the following information

Nodetool status:

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load        Tokens  Owns (effective)  Host ID                               Rack 
UN  172.17.0.2  151.72 KiB  16      100.0%            222503c6-0030-43a6-a365-c61aae4b9765  rack1

Cqlsh output:

root@2e8cb70614b1:/# cqlsh
WARNING: cqlsh was built against 5.0-beta1, but this server is 5.0.  All features may not work!
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.2.0 | Cassandra 5.0-beta1 | CQL spec 3.4.7 | Native protocol v5]
martin-sucha commented 4 months ago

Hello! The support in gocql for v5 is for an old beta version of the v5 protocol, the final version is not supported yet: https://github.com/gocql/gocql/issues/1522

testisnullus commented 4 months ago

Thank you, @martin-sucha. Will try to reflect new changes to support the v5 protocol for Cassandra in GoCQL. Do you have any suggestions on how to acquire the contributor role to be able to review and merge PRs?