Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Membase | Membase Server 1.7.x

negative cas values on gets

6 replies [Last post]
  • Login or register to post comments
Tue, 01/24/2012 - 09:53
dan
Offline
Joined: 01/05/2011
Groups: None

spymemcached-2.7.1
membase 1.7.1
membase buckets

This is a problem we've had for a while but it's getting worse and worse. We do a gets to grab a key, apply some transformation to the value and go to do a cas operation. However, the cas value from the gets is negative and so the attempt to use cas fails. We end up doing a set instead.

Does anyone else see this happening?

Top
  • Login or register to post comments
Thu, 02/02/2012 - 12:38
mikew
Offline
Joined: 03/14/2011
Groups:

Do you use getl or are you locking keys in any way in your application?

Top
  • Login or register to post comments
Fri, 02/03/2012 - 09:24
dan
Offline
Joined: 01/05/2011
Groups: None

Mike, we don't use getl and are not locking the key

Here's a code snippet

CASValue strCas = mc.gets ( key );
long casId = 0;
 
if ( strCas != null )
{
	casId = strCas.getCas ();
}
 
/*
	...
	Code to modify the result
	...
*/
 
if (casId < 0 )
{
	Logger.getLogger ( Main.class.getName () ).log ( Level.WARN, "Error with casId: " + casId );
	Future future = mc.set ( key, membaseExpire, Arrays.copyOfRange ( output, 0, compressedDataLength ), mc.getTranscoder () );
	future.get();
}
else
{
	CASResponse cr = mc.cas ( key, casId, membaseExpire, Arrays.copyOfRange ( output, 0, compressedDataLength ), mc.getTranscoder () );
}

We log each time we have to do a set instead of cas and I've noticed that a lot of the casId values are in the -2 billion range (according to the memached spec cas values are 64bit, and I never see any values greater than 2 billion, so....). I'm wondering if this is an integer overflow issue. Looking through spymemecahed casId is always represented as a long so I'm guessing it's possibly in membase.

Thanks for the help,
Dan

Top
  • Login or register to post comments
Fri, 02/03/2012 - 09:40
dan
Offline
Joined: 01/05/2011
Groups: None

I should note that if we try to loop doing a gets/cas the casId still never match and it sits in an infinite loop forever. Overwriting the key with a set seems to the be the only solution.

Top
  • Login or register to post comments
Fri, 02/03/2012 - 12:31
mikew
Offline
Joined: 03/14/2011
Groups:

Dan,

This was a bug that I actually fixed a few months ago. Your actually one release behind and if you upgrade to Spy 2.7.2 (I recommend upgrading to Spy 2.7.3 though) then you shouldn't see this issue any more. Below is a link to the commit that fixed this issue:

https://github.com/dustin/java-memcached-client/commit/5c2c773a361f34034...

If you still experience this issue after upgrading please let me know.

Top
  • Login or register to post comments
Fri, 02/03/2012 - 13:03
dan
Offline
Joined: 01/05/2011
Groups: None

Mike, I downloaded 2.7.3 a while ago but had not pushed it to every thing yet. I'll let you know if the errors go away.

Thanks again for the help,
Dan

Top
  • Login or register to post comments
Wed, 02/08/2012 - 08:33
dan
Offline
Joined: 01/05/2011
Groups: None

The good news is I don't see negative cas values anymore, the bad news is I started seeing a number of failures with our getBulk operations so I reverted back to 2.7.1 on our projects that use getBulk.

I haven't had time to look into it further but I will update this thread when I do.

Dan

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker