首页 文章

在CAS操作上获取WriteTimoutException

提问于
浏览
0

我试图使用phantom插入相当少量的数据异步到 cassandra 3:9 但是这个查询保持失败: INSERT INTO test_db.test_tbl(name, last, ts) VALUES('aaa', 'bbb', 1502109409) IF NOT EXISTS USING TTL 0; 我收到以下异常:

com.datastax.driver.core.exceptions.WriteTimeoutException:在com.datastax.driver.core.exceptions.WriteTimeoutException.copy(WriteTimeoutException)的一致性SERIAL(需要1个副本但只有0确认写入)的写查询期间的Cassandra超时 . 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 .. ...

我正在用docker运行cassandra . 我试图改变cassandra.yaml write_request_timeout_in_ms: 20000 ,但这并没有太大的区别 .

更新:我尝试将一致性级别设置为ONE(也尝试其他):

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

但异常仍然显示“在一致性SERIAL写入查询期间Cassandra超时”

1 回答

  • 0

    您正在使用 IF NOT EXISTS 关键字,这是Lightweight transactions

    Cassandra通过扩展Paxos共识协议来实现轻量级事务,该协议基于基于仲裁的算法 . Paxos以四次往返的成本确保线性化的一致性 .

    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 .

    资料来源:https://www.datastax.com/dev/blog/lightweight-transactions-in-cassandra-2-0

相关问题