You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Joe Pallas <pa...@cs.stanford.edu> on 2011/01/31 22:14:38 UTC

How does checkAndPut guarantee atomicity?

It's easy to understand how single-row operations can be atomic, but checkAndPut allows a check on one row and a put on another while promising this will be atomic.  Is it really guaranteed to be atomic in that case?  How does that work if the two rows are in different regions (and possibly different RegionServers)?

Thanks.
joe


Re: How does checkAndPut guarantee atomicity?

Posted by Ryan Rawson <ry...@gmail.com>.
Hi,

Good catch, while the API does let you specify 2 different row keys,
one in the 'put' and one in the call, doing so would be ... not
advised.  Right now there is no check for this, and if you were to
pass 2 different rows, things would not be so good.

Here is an issue:
https://issues.apache.org/jira/browse/HBASE-3494

I just created for this.

So, basically, no, checkAndPut shouldn't (!) allow a check on 1 row
and a put on another, and even though it appears possible in the
current code base, there is no promise of atomicity and you might end
up with lame things, like rows for a different region in the wrong
region. ouch!

-ryan

On Mon, Jan 31, 2011 at 1:14 PM, Joe Pallas <pa...@cs.stanford.edu> wrote:
> It's easy to understand how single-row operations can be atomic, but checkAndPut allows a check on one row and a put on another while promising this will be atomic.  Is it really guaranteed to be atomic in that case?  How does that work if the two rows are in different regions (and possibly different RegionServers)?
>
> Thanks.
> joe
>
>