Hi,

I am experimenting with C* 2.0 ( and today's java-driver 2.0 snapshot) for 
implementing distributed locks.

Basically, I have a table  of 'states' I want to serialize access to:

  create table state ( id text , lock uuid , data text, primary key (id) )   (3 
nodes, replication level 3)

  insert into state (id) values ( 'foo')

I try to akquire the lock for state 'foo' like this:

  update state set lock = myUUID where id = 'foo' if lock = null;

and check whether I got it by comparing the lock against my supplied UUID:

   select lock from state where id = 'foo'; 

... do work on 'foo' state ....

release lock:

 update state set lock = null where id = 'foo' if lock = myUUID;


This works pretty well and if I increase the number of clients competing for 
the lock I start seeing timeouts on the client side. Natural so far and the 
lock also remains in a consistent state (it works to work around the failing 
clients and the uncertainty whether they got the lock or not).

However, after pausing the clients for a while the timeouts do not disappear. 
Meaning that when I send a single request after everything calms down , I still 
get a timeout:

   Caused by: com.datastax.driver.core.exceptions.WriteTimeoutException: 
Cassandra timeout during write query at consistency SERIAL (-1 replica were 
required but only -1 acknowledged the write)

I do not see any reaction in the C* logs for these follow-up requests that 
still time out.

Any idea how to approach this problem?

Jan




Reply via email to