Getting WriteTimoutException on CAS operations

Viewed 3384

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"

2 Answers

Same problem,this is my solution:

It only fit a single node.

  1. Execute the LWT CQL once,close and init Session once. use com.datastax.driver.core.Session.init().

  2. Cluster.Builder.setConsistencyLevel(ConsistencyLevel.QUORUM)

  3. Cluster.Builder.withSocketOptions(newSocketOptions().setConnectTimeoutMillis(300000) .setReadTimeoutMillis(300000));

Related