Hi,

Just started developing using Cassandra (0.8.4). I noticed when
updating the same row and column repeatedly, say, in a test case,
updates may get lost. I found it in a Java client but the following
python script also exhibits the same problem.

******************************************************************
import pycassa
import time

pool = pycassa.ConnectionPool('TestKeySpace', server_list=['localhost'])

cf = pycassa.ColumnFamily(pool, 'blah')

for i in range(1, 1000):
        cf.insert('foo', {'body': 'aaa'})
        assert 'aaa'==cf.get('foo')['body']     
        cf.insert('foo', {'body': 'bbb'})
        assert 'bbb'==cf.get('foo')['body']
        #time.sleep(0.015)

        print i
******************************************************************

The script errors out at assertion, when the value is supposed to be
updated back to 'aaa' from 'bbb'

******************************************************************
$ python test.py
1
Traceback (most recent call last):
  File "test.py", line 10, in <module>
    assert 'aaa'==cf.get('foo')['body']
AssertionError
******************************************************************

If the client sleeps for a few ms at each loop, the success rate
increases. At 15 ms, the script always succeeds so far. Interestingly,
the problem seems to be sensitive to alphabetical order. Updating the
value from 'aaa' to 'bbb' never has problem. No pause needed.

Is this a real problem or I'm missing something about how Cassandra
works? Only one Cassandra instance is used in the test.

Thanks.

Jiang

Reply via email to