negative cas values on gets
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?
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
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.
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.
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
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
Do you use getl or are you locking keys in any way in your application?