memcached icon indicating copy to clipboard operation
memcached copied to clipboard

Parallel increment on key

Open baltazorbest opened this issue 8 years ago • 2 comments

Hello. OS: Centos 6.8 x86_64 with latest updates. I have 2 node Tarantool 1.7.1.117 with master-master replication for testing and plugin memcached 0.1.0. When I try at the same time the increment for a single key with two running script on two different masters, the first script updates the key on one master, another script updates the key on another master, I do not get the correct value of the key. It should be 2000000 and get for example 882 392 or 892 956.

PHP script: $mc = new Memcache; $mc->pconnect("ip_master_1_or_2", 11211); $key = "COUNTER"; $mc->set($key, 1, 0, 7200); for($i=0;$i<1000000;$i++) { $mc->increment($key); }

I try this method with tarantool php client, and everything works correctly, the result: 2000000, and I try this method for Memcached, and everything works correctly, result: 200001.

baltazorbest avatar Jul 31 '16 15:07 baltazorbest

Is there any error messages in tarantool log file? Maybe it has become inconsistent? I think that I need to rewrite INC/DEC operation using CRDT with Upsert.

and I try this method for Memcached, and everything works correctly, result: 200001.

As i've guessed, you've setup client-side replication for Memcached? And for Tarantool you've set up server-side replication?

I try this method with tarantool php client, and everything works correctly, the result: 2000000

Why results are different there? I suppose it's because initial values are different?

bigbes avatar Aug 01 '16 10:08 bigbes

Is there any error messages in tarantool log file? Maybe it has become inconsistent? I think that I need to rewrite INC/DEC operation using CRDT with Upsert.

No error. When I get values from master one and master two, values are the same.

As i've guessed, you've setup client-side replication for Memcached? And for Tarantool you've set up server-side replication?

Server memcached without replication, Tarantool with replication master-master.

Why results are different there? I suppose it's because initial values are different?

Yes, initial values are different.

baltazorbest avatar Aug 01 '16 11:08 baltazorbest