Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting WriteTimoutException on CAS operations

I am trying to insert fairly small amount of data async using phantom to cassandra 3:9 however this query keeps fails : INSERT INTO test_db.test_tbl(name, last, ts) VALUES('aaa', 'bbb', 1502109409) IF NOT EXISTS USING TTL 0; I am getting the following exception :

com.datastax.driver.core.exceptions.WriteTimeoutException: Cassandra timeout during write query at consistency SERIAL (1 replica were required but only 0 acknowledged the write)

at com.datastax.driver.core.exceptions.WriteTimeoutException.copy(WriteTimeoutException.java:100)

at com.datastax.driver.core.Responses$Error.asException(Responses.java:134)

at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:507)

at com .....

I am running cassandra with docker. I tried to change the cassandra.yaml write_request_timeout_in_ms: 20000 but that didn't made much difference.

UPDATE: I tried setting the consistency level to ONE (also tried other):

insert
      .value(_.name, "aaa")
      .value(_.last, uuid)
      .value(_.ts, Random.long)
      .ifNotExists()
      .consistencyLevel_=(ConsistencyLevel.ONE)

but the exception still shows "Cassandra timeout during write query at consistency SERIAL"

like image 731
igx Avatar asked Mar 06 '26 09:03

igx


1 Answers

You are using IF NOT EXISTS keyword, which is a Lightweight transactions

Cassandra implements lightweight transactions by extending the Paxos consensus protocol, which is based on a quorum-based algorithm. Paxos make sure linearizable consistency at the cost of four round trips.

That sounds like a high cost—perhaps too high, if you have the rare case of an application that requires every operation to be linearizable. Consequently, reserve lightweight transactions for those situations where they are absolutely necessary.

Source : https://www.datastax.com/dev/blog/lightweight-transactions-in-cassandra-2-0

like image 159
Ashraful Islam Avatar answered Mar 09 '26 07:03

Ashraful Islam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!