Skip to content
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

CASSGO-26 Impossible to set CONSISTENCY SERIAL (select consistency) #1832

Open
danthegoodman1 opened this issue Oct 16, 2024 · 8 comments · May be fixed by #1837
Open

CASSGO-26 Impossible to set CONSISTENCY SERIAL (select consistency) #1832

danthegoodman1 opened this issue Oct 16, 2024 · 8 comments · May be fixed by #1837

Comments

@danthegoodman1
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Cassandra are you using?

ScyllaDB

What version of Gocql are you using?

1.7.0

What version of Go are you using?

1.22.5

The .Consistency options don't allow for setting SERIAL or LOCAL_SERIAL, despite them being supported by both Cassandra and Scylla for reads to use Paxos.

type Consistency uint16

const (
	Any         Consistency = 0x00
	One         Consistency = 0x01
	Two         Consistency = 0x02
	Three       Consistency = 0x03
	Quorum      Consistency = 0x04
	All         Consistency = 0x05
	LocalQuorum Consistency = 0x06
	EachQuorum  Consistency = 0x07
	LocalOne    Consistency = 0x0A
)

Because the driver does not allow you to session.Query("CONSISTENCY SERIAL").Exec() (get's error no viable alternative at input 'CONSISTENCY'), it seems to be currently impossible to set SELECT consistency to SERIAL

@danthegoodman1 danthegoodman1 changed the title Impossible to set SERIAL and LOCAL_SERIAL CONSISTENCY for reads Impossible to set CONSISTENCY SERIAL (select consistency) Oct 16, 2024
@dkropachev
Copy link

dkropachev commented Oct 16, 2024

@danthegoodman1 , have you tried Query.SerialConsistency ?
Also if you working with ScyllaDB, it is better to submit issues at https://github.com/scylladb/gocql

@danthegoodman1
Copy link
Author

@dkropachev sorry I was inspecting this issue more at the package level, it seems like they support it https://github.com/scylladb/gocql/blob/master/frame.go#L187-L188 but this package does not (which is strange, considering cassandra supports it: https://docs.datastax.com/en/cql/hcd-1.0/reference/cqlsh-commands/consistency.html#setting-a-consistency-level)

@OleksiienkoMykyta
Copy link
Contributor

@danthegoodman1 according to gocql documentation (for batch: https://pkg.go.dev/github.com/gocql/gocql#Batch.SerialConsistency, for query: https://pkg.go.dev/github.com/gocql/gocql#Query.SerialConsistency) the SerialConsistency supports only conditional update/insert operations. I will test if it works this way.

@danthegoodman1
Copy link
Author

And if so, the problem is there becomes no way to use that Cassandra feature in this package then.

@OleksiienkoMykyta
Copy link
Contributor

OleksiienkoMykyta commented Oct 25, 2024

@danthegoodman1 I have tested it and compared behavior with the Python driver as well as cqlsh and ensured that everything works according to the documentation (https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v5.spec). To set SERIAL consistency you can do the following

	cluster := gocql.NewCluster("***.**.*.*:****")
	cluster.Keyspace = "test"
	cluster.SerialConsistency = gocql.Serial

or directly to query

session.Query("INSERT INTO test.test_table (id) VALUES (1) IF NOT EXISTS").SerialConsistency(Serial)

It will set the SERIAL consistency level for the serial phase of conditional updates.
After that, you can check the frame content and ensure that the serial_consistency is presented as SERIAL.

[execute id=52 FC 92 9D FB 65 5C 36 6E 37 68 E1 C6 15 87 8F params=[query_params consistency=QUORUM skip_meta=true page_size=5000 paging_state="" serial_consistency=SERIAL default_timestamp=true values=[] keyspace=]]

@danthegoodman1
Copy link
Author

Not the SERIAL CONSISTENCY, CONSISTENCY SERIAL, which is used for paxos reads.

Subtle difference, but SERIAL CONSISTENCY is only used for LWTs. See how https://docs.datastax.com/en/cassandra-oss/2.2/cassandra/dml/dmlConfigConsistency.html#Readconsistencylevels is different than https://docs.datastax.com/en/cassandra-oss/2.2/cassandra/dml/dmlConfigSerialConsistency.html

@OleksiienkoMykyta OleksiienkoMykyta linked a pull request Oct 28, 2024 that will close this issue
@OleksiienkoMykyta
Copy link
Contributor

@danthegoodman1 sorry for the misunderstanding, now I see the problem. Inspired by (https://github.com/scylladb/gocql/blob/master/frame.go#L187-L188) I added this feature, and now it should work properly.

@danthegoodman1
Copy link
Author

Thank you!

@joao-r-reis joao-r-reis changed the title Impossible to set CONSISTENCY SERIAL (select consistency) CASSGO-26 Impossible to set CONSISTENCY SERIAL (select consistency) Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@danthegoodman1 @dkropachev @OleksiienkoMykyta and others