Cassandra-driver acquiring tstate_lock in python3.6/threading.py while doing cluster.connect and got stuck forever

24 views
Skip to first unread message

Pankaj Kumar

unread,
Feb 4, 2020, 6:46:18 AM2/4/20
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi,
We are running cassandra using mock cassandra and interacting with python cassandra-driver. We are running python3.6 and we are using latest cassandra-driver i.e cassandra-driver 3.21.0.
What we are seeing is when calling cluster.connect it is trying to acquire a tstate_lock from here https://github.com/python/cpython/blob/3.6/Lib/threading.py#L1072 but we are running another process which has acquired this lock already, here https://github.com/python/cpython/blob/3.6/Lib/threading.py#L899 but here the lock that is acquired is not getting released, it will be released after the process who has acquired the lock gets killed. So my program got stuck at cluster.connect call forever.

My question is why cluster.connect is trying to acquire that lock in latest cassandra-driver?? Is there any way we can avoid this from driver side which is acquiring the lock and so that my program can go further??

Traceback (most recent call first):
 
<built-in method acquire of _thread.lock object at remote 0x7f4c11dd4030>
 
File "/usr/lib64/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
   
elif lock.acquire(block, timeout):
 
File "/usr/lib64/python3.6/threading.py", line 1056, in join
   
self._wait_for_tstate_lock()
 
<cython_function_or_method at remote 0x7f4c180691b8>
 
File "/root/mockcassandra.py", line 179, in verify_cassandra
    session
= cluster.connect()


In the traceback, cluster.connect are trying to acquire the tstate_lock which is already acquired by another process and not releasing it until that process gets killed.
Can anyone suggest how can we proceed further?

Alan Boudreault

unread,
Feb 4, 2020, 7:54:11 AM2/4/20
to python-dr...@lists.datastax.com
Hi Pankaj,

Unfortunately, I don´t know what is mockcassandra.py. I suspect you are experiencing a threading python issue. There are some similar errors reported on different sites/projects. The driver is using some locks for some internal state modifications.. but nothing special. Something you could try first is to update your Python runtime to the latest 3.6.x release to ensure you have all bug fixes. 

Regards
Alan

--
To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-u...@lists.datastax.com.


--
Alan Boudreault
Software Engineer (Drivers) | alan.bo...@datastax.com



Pankaj Kumar

unread,
Feb 6, 2020, 11:38:30 AM2/6/20
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi Alan,

Mockcassandra.py is our test code where we test running of cassandra. So there we are calling cluster.connect which is trying to acquire the lock in python threading library but that lock is already acquired by some other process but the lock release code is not there in library, as I mentioned earlier.

I am using python 3.6.8 and seeing this issue. I tried this with python 3.7.2 also and seeing the same issue.


File "/usr/local/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock


    elif lock.acquire(block, timeout):


  File "/usr/local/lib/python3.7/threading.py", line 1032, in join


    self._wait_for_tstate_lock()


  File "/root/mockcassandra.py", line 179, in verify_cassandra


    session = cluster.connect()


 I am stuck here actually.
To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-user+unsub...@lists.datastax.com.

Alan Boudreault

unread,
Feb 6, 2020, 11:45:18 AM2/6/20
to python-dr...@lists.datastax.com
Could you create a small test case script that I can run here? without mockcassandra, only the driver.

Thanks,
Alan

To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-u...@lists.datastax.com.


--
Alan Boudreault
Software Engineer (Drivers) | alan.bo...@datastax.com



--
To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-u...@lists.datastax.com.
Reply all
Reply to author
Forward
0 new messages