Hi David

You are right that the write path for atomic compare and swap would become as 
slow as the read path but that would be for compare and swap operation only. In 
general the writes can remain fast and need not be changed in any way. I mean 
we don't have to slow down writes, only the compare and swap writes for a 
column would need to be slow. Can't we say that there is no guarantee if normal 
write for a column interferes with a compare and swap operation for the same 
column. The user (client) needs to take care of not to use compare and swap and 
normal writes on the same column.

Heres another thought I had, if say the user always wrote with quorum (or to 
all) nodes then can't we implement CAS (compare and swap) assuming that user 
employs logical timestamp and Cassandra doesn't allow writes to a column with 
same or older timestamp. Here's the scenario I am thinking about:
Say we use logical timestamp for a column value and lets assume the current 
timestamp is t. Now say two clients read this column and generate concurrent 
CAS (compare and swap) operations on timestamp t and for both the writes the 
resulting new timestamp would become (t+1). Now if we don't allow writes to a 
column with same timestamp then only one of these writes would succeed. Of 
course another assumption is that if a third CAS write with compare on logical 
timestamp (t - 1) came in, that would be denied as I believe Cassandra doesn't 
allow "older" writes to win over "newer" writes. Do you think such a thing can 
be accomplished?

Thanks for all the help,
Rishi





________________________________
From: David Timothy Strauss <da...@fourkitchens.com>
To: dev@cassandra.apache.org
Sent: Sun, June 20, 2010 3:08:18 PM
Subject: Re: Atomic Compare and Swap

That is impossible to implement without making the write path at least as slow 
as the read path. Things like this typically get layed on Cassandra by using an 
external locking framework, like Zookeeper.

-----Original Message-----
From: Rishi Bhardwaj <khichri...@yahoo.com>
Date: Sun, 20 Jun 2010 14:57:46 
To: <dev@cassandra.apache.org>
Reply-To: dev@cassandra.apache.org
Subject: Atomic Compare and Swap

Hi

I was wondering if Cassandra has any plans for supporting atomic compare and 
swap operation on a column value? Compare could be on timestamp for the column 
or the column value itself and the write of course is on the column value + a 
new timestamp. If there are no plans on supporting such an operation, how 
difficult would it be to implement such a functionality? I would be interested 
to start working on this if no one else is doing so and would really appreciate 
any pointers in the right direction in how to contribute here.

Thanks,
Rishi


      

Reply via email to