简体   繁体   English

卡桑德拉一致性失败

[英]Cassandra consistency fails

[Update] [更新]

The previous statement was quite misleading so I am elaborating more here: 先前的陈述很容易引起误解,因此我在这里进行详细说明:

I ran a test that sends out queries via Thrift protocol in PHP and the script looks like: 我运行了一个测试,该测试通过PHP中的Thrift协议发送了查询,脚本如下所示:

for ($i=0; $i<100; $i++) {  
    $query = "update ns.table set value='before' where key='key$i';";  
    // randomly select a node and send query  
}  

for ($i=0; $i<100; $i++) {  
    $query = "update ns.table set value='after' where key='key$i';";  
    // randomly select a node and send query  
}  

The table started as empty, and after the test only certain rows contain the value "after" while most rows contain "before". 该表开始为空,并且在测试之后,仅某些行包含值“ after”,而大多数行包含“ before”。

I did not receive any error throughout the test. 在整个测试过程中,我没有收到任何错误。 So somehow the queries in the second loop failed silently. 因此,第二个循环中的查询以某种方式静默失败。

All queries are sent with consistency level ALL, and the table has a replication factor of 2. 所有查询均以一致性级别ALL发送,并且该表的复制因子为2。

My cassandra version is DSE 4.6.3, and the cluster has a total of 39 nodes. 我的cassandra版本是DSE 4.6.3,该群集共有39个节点。

[Update2] [UPDATE2]

After putting a sleep (for 3 seconds) in between the two loops the test can now give me correct result, with all rows in the table having the value "after". 在两个循环之间进行睡眠(3秒钟)后,测试现在可以为我提供正确的结果,表中的所有行的值均为“ after”。

But this is still confusing since for consistency level ALL I am expecting all queries to be made transactionally. 但这仍然令人困惑,因为对于一致性级别ALL,我希望所有查询都以事务方式进行。 No need for the sleep function. 无需睡眠功能。

After syncing the clocks of nodes the issue has been resolved. 同步节点的时钟后,问题已解决。

Thanks @mshuler for pointing out. 感谢@mshuler指出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM