Comment #4 on issue 220 by [email protected]: Binary Increment returns old cas
http://code.google.com/p/memcached/issues/detail?id=220
I tested this using the 1.4.7 Aug 16 release and the bug is there.
-=Bug Explanation=-
The reason why that exact block of code won't work at the end of
do_add_delta is because it's getting the return cas from "it". The new cas
that should be returned is assigned to "new_it" in "item_replace(it,
new_it)". Two possible fixes would either be:
1) insert logic in item_replace to copy over the cas from the "new_it"
to "it" or
2) in do_add_delta, put the block of code I've typed in comment 2 after
line 2906 in do_add_delta and return OK.
-=Easy Way to Reproduce Bug=-
I've also found an easy way to replicate the error:
1) startup memcached with verbose mode "memcached -vvv"
2) send custom packet to set the key "Bob" with value "100" using the
following command in Ubuntu:
echo
-en '\x80\x01\x00\x03\x08\x00\x00\x00\x00\x00\x00\x0e\xde\xad\xbe\xef\x00\x00\x00\x00\x00\x00\x00\x00\xc8\x11\x00\x00\x00\x00\x00\x00\x42\x6f\x62\x31\x30\x30'
| nc localhost 11211
2.5) Take note of the CAS ID in the response header by looking at the
verbose output.
3) Send packet to increment "Bob" by 999 using the command:
echo
-en '\x80\x05\x00\x03\x14\x00\x00\x00\x00\x00\x00\x17\xde\xad\xbe\xef\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xE7\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x42\x6f\x62'
| nc localhost 11211
4) Note that the CAS in the return packet is the same as the one in step
2.5 (even if you had other successful set/add/replace commands between
steps 2 and 3). This means that the old cas is being returned.
I hope the extra info helps.