Closed GoogleCodeExporter closed 9 years ago
Traced down the cause of the behavior, as well as some other issues with
spymemcached clients just
basically taking themselves out of service:
In net.spy.memcached.protocol.binary.OperationImpl:
/**
* Generate an opaque ID.
*/
static int generateOpaque() {
int rv=seqNumber.incrementAndGet();
while(rv < 0) {
if(seqNumber.compareAndSet(rv, 0)) {
rv=seqNumber.incrementAndGet();
}
}
return rv;
}
If the cas op on seqNumber fails, rv never gets updated and will loop until
seqNumber wraps at least one
more time. proposed fix increments seqNumber whether or not the cas succeeds:
if another thread was able
to swap to 0 before we were, we're still good to go.
/**
* Generate an opaque ID.
*/
static int generateOpaque() {
int rv=seqNumber.incrementAndGet();
while(rv < 0) {
seqNumber.compareAndSet(rv, 0);
rv=seqNumber.incrementAndGet();
}
return rv;
}
Original comment by lewiszim...@gmail.com
on 13 Oct 2009 at 6:02
Hey, thanks a lot for the fix. That makes a lot of sense.
I committed 4e4b9ff3afba4282fa21d719fe9095be3fc97cc7 as you.
Original comment by dsalli...@gmail.com
on 13 Oct 2009 at 8:32
Original issue reported on code.google.com by
lewiszim...@gmail.com
on 29 Sep 2009 at 7:45