You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Kevin Burton <bu...@spinn3r.com> on 2014/11/16 08:01:19 UTC

Two writers appending to a set to see which one wins?

I have two tasks trying to each insert into a table.  The only problem is
that I only want one to win, and then never perform that operation again.

So my idea was to use the set append support in Cassandra to attempt to
append to the set and if we win, then I can perform my operation.  The
problem is, how.. I don’t think there’s a way to find out that your INSERT
successfully added or failed a set append.

Is there something I’m missing?

Kevin

-- 

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>
<http://spinn3r.com>

Re: Two writers appending to a set to see which one wins?

Posted by Eric Stevens <mi...@gmail.com>.
You may be able to do something with conditional updates, however trying to
use Cassandra for this kind of coordination smells to me a lot like typical
antipatterns (eg write then read or read then write).  You probably would
do better if you need one writer to consistently win a race condition over
another if you manipulated timestamps, such as having the lower priority
node write with a timestamp of now minus a few seconds.

Otherwise if you need this kind of cross-node coordination and
responsibility assignment, a purpose built tool like Zookeeper would
probably be a better idea and give more predictable and consistent results.

On Sun Nov 16 2014 at 12:03:18 AM Kevin Burton <bu...@spinn3r.com> wrote:

> I have two tasks trying to each insert into a table.  The only problem is
> that I only want one to win, and then never perform that operation again.
>
> So my idea was to use the set append support in Cassandra to attempt to
> append to the set and if we win, then I can perform my operation.  The
> problem is, how.. I don’t think there’s a way to find out that your INSERT
> successfully added or failed a set append.
>
> Is there something I’m missing?
>
> Kevin
>
> --
>
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
> <http://spinn3r.com>
>
>