1

I'm new to distributed databases and there are a couple of things I couldn't figure out.
We're developing an application and need to select the right database, this application needs strong consistency on financial data related to users, like deposit and withdraws. I am wondering about tunable consistency in Cassandra, specifically quorum level of consistency.
Imagine the following scenario:
Replication factor is 3.
Initial balance of a user John is 10 on all replicas.
At time t1, an update is happening on John's balance reducing it to 7 (CL=quorum),
Simultaneously, at time t1, a read operation is being run with consistency level set on quorum which is 2 in this case.
Is it possible that the replica on the node where update query is executing on, is not selected for the quorum?
If so, Is it right to assume that the result of read operation would be 10 because there's no write lock?
Overall I'd like to know if it is possible for John to somehow exploit this and spend more than his account's balance.
Thanks.

  • 1
    What is the consistency level for update operation? – Alex Ott Nov 27 '17 at 19:53
  • @AlexOtt Thanks for reminding me! I've edited the question, CL for the update operation is set on quorum. – Sam Nov 27 '17 at 20:06
2

With having QUORUM for both read & write requrests you achieve strong consistency per following equation R + W > N, where R - read replica count, W - write replica count, and N - replication factor.

If you write with QUORUM, then 2 nodes will get fresh data, and when you read with QUORUM, then one node may have the old data, and one will have fresh data - Cassandra will detect discrepancy & use the newest version.

  • So basically my concern for 'double spending' problem due to old data is irrelevant. Am I getting this right? – Sam Nov 28 '17 at 11:09
  • Yes - you are right. Although for money I maybe prefer to use consistency level ALL for writes... – Alex Ott Nov 28 '17 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.