scylladb/gocqlx

LWT query showing default consistency of QUORUM in query

Closed this issue · 4 comments

ScyllaDB 4.4.4-0.20210801.69daa9fd0 (docker container)

gocqlx v2.4.0

What version of Go are you using?

go version go1.17 darwin/amd64

What did you do?

Attempted the following query builder query:

// Insert if not exists
q := qb.Insert(db.IdentityMetadata.Name).
	Columns(db.IdentityMetadata.Columns...).
	Unique(). // IF NOT EXISTS
	Query(*db.DBSession).
	SerialConsistency(gocql.Serial).
	BindMap(map[string]interface{}{
		"namespace":   namespaceID,
		"id":          identityID,
		"password_id": "crap",
		"auth_method": "email",
		"created_at":  time.Now(),
		"updated_at":  time.Now(),
		"verified":    false,
		"active":      true,
		"traits":      "blah",
		"credentials": "kreuighr",
	})

applied, err := q.ExecCASRelease()

WIth the following output:

[query statement="INSERT INTO identities ...] consistency=QUORUM]

What did you expect to see?

I would expect SERIAL consistency

What did you see instead?

The following result showed a consistency of QUORUM

Edit:

I will add that it seems to be doing a transaction still, at least IF EXISTS and IF NOT EXISTS still seem to be respected, but I can't determine whether this is actually happening in a transaaction due to the shown consistency level.

I've also found that if I do a q.SetConsistency(gocql.Consistency(gocql.Serial)) I get the following with no errors:

consistency=UNKNOWN_CONS_0x8

Another thing I have noticed is the docs say:

This option will be ignored for anything else that a conditional update/insert.

However doing a IF EXISTS on a delete query and using the serial consistency seems to work.

This is how I am connecting:

func DBConnect() {
	var cluster *gocql.ClusterConfig
	scyllaHost := os.Getenv("SCYLLA_HOST")
	if scyllaHost == "" {
		cluster = gocql.NewCluster("localhost:9042")
	} else {
		cluster = gocql.NewCluster(scyllaHost)
	}
	cluster.Keyspace = "identity_ksp"

	session, err := gocqlx.WrapSession(cluster.CreateSession())
	utils.HandleError(err)

	DBSession = &session
}