Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started



HDC avatar image
HDC asked Erick Ramirez answered

cassandra 写入的副本不一致

cassandra 版本:2.1.15


CREATE KEYSPACE keyspace1 WITH REPLICATION = {'class': 'NetworkTopologyStrategy','DC1': '3','DC2':'3'};







./sstable2json /disk/data2/cassandra/keyspace1/table-094aa0a0fa4311eab69565744744aa23/keyspace1-table-ka-207621-Data.db -k ID_1


{"key": "ID_1",

"cells": [["000:111:AAA:222:field_1","BBB",1620896500311001],


["000:111:AAA:222:field_3","2021-05-13 17:01+0800",1620896500311001],

["000:111:AAA:222:field_4","2021-05-13 17:01+0800",1620896500311001]]}


./sstable2json /disk/data2/cassandra/keyspace1/table-094aa0a0fa4311eab69565744744aa23/keyspace1-table-ka-724373-Data.db -k ID_1


{"key": "ID_1",

"cells": [["000:111:AAA:222:field_1","BBB",1620896500311001]]}




10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

A mutation (Cassandra write) is applied to replicas as a single atomic operation. It is not possible for only some rows in the mutation to be applied -- all of the rows of a single mutation must be written successfully or the replica will not send a successful write acknowledgement to the coordinator of the request.

In your case, it is not possible for the same mutation to only apply one row to node2 but four rows to node1 and none for node3. The likely scenario is that those are separate write requests.

The important thing to focus on is that all 3 replicas are out-of-sync. For this situation to take place, your application is writing with a consistency of ONE or LOCAL_ONE. This is bad practice and leads to data inconsistencies like you're experiencing.

Our recommendation is to use LOCAL_QUORUM so at least 2 replicas must acknowledge the write and avoids this situation. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.