Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

WRB avatar image
WRB asked WRB commented

How do I switch native protocol versions during a rolling upgrade?

I'm upgrading my cassandra from 2.1.x to 3.11.x, and I'm using datastax driver 3.3.1.

I learned from this document https://docs.datastax.com/en/cassandra-oss/3.x/cassandra/operations/opsMoveCluster.html that I need to have client writing to both 2.1 and 3.11 clusters.

However, datastax 3.3.1 driver dont support mixed native protocols, as it says in document https://docs.datastax.com/en/developer/java-driver/3.3/manual/native_protocol/. and if I want to upgrade my clusters, I need to do this:

  • always force a protocol version at startup. You keep it at v2 while the rolling upgrade is happening, and only switch to v3 when the whole cluster has switched to Cassandra 2.1;

but the same document also says The protocol version cannot be changed at runtime.

questions:

1. How to switch native protocol at runtime without shutdown ?

2. Can client write to clusters with different native protocol the same time ?

java drivernative protocol
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered WRB commented

It seems like you misunderstood the document. Cassandra 2.1 supports native protocol v3 while Cassandra 3.11 supports native protocol v4.

Since you're using Java driver 3.3, you need to force native protocol v3 (C* 2.1) before upgrading the cluster, for example:

Cluster cluster = Cluster.builder()
    .addContactPoint("127.0.0.1")
    .withProtocolVersion(ProtocolVersion.V3)
    .build();

By forcing a protocol version, the driver will "talk" to all nodes using a specific version. Cassandra 3.11 nodes are backward compatible with the previous major version so they can negotiate to v3.

Once all nodes in the cluster have been upgraded to Cassandra 3.11, you can remove withProtocolVersion() from your application code and the driver will automatically negotiate to native protocol v4. Since this is a code change, it will require an application restart for the change to take effect. Cheers!

3 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks! Now I understand 3.11 nodes can negotiate to v3.

However the applications restart might be unacceptable for my colleagues. And I realized the scenario isn't quite like the document. The document is talking about one cluster with mixed protocol versions. But I'm dealing with two clusters, one supports v3 and the other v4.

my questions:

  • Since my applications is already using v3 before I ever force it, would it continue using v3 if I add a cassandra 3.11 contact point in my springboot cassandra configuration?
  • Is there a way to avoid restart? For example, can I interpret protocol v3 to v4 when accessing through DAL?

I appreciate any further advice, thanks.

0 Likes 0 ·
No, no and no. An app instance restart is unavoidable during a major upgrade. However, that should be of no consequence since you should have a farm of app instances in production which means there should be no impact when you perform a rolling restart. Cheers!
0 Likes 0 ·
WRB avatar image WRB Erick Ramirez ♦♦ ·

thanks a lot!

0 Likes 0 ·