kragniz / kragniz/python-etcd3

Exception when many threads wait to acquire etcd3 lock

Open
#369 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
450
Forks
194
PR merge metrics
No merged PRs in 30d

Description

When 10 threads wait to acquire the etcd3 lock, I see this exception sometimes:

```
with etcd_client.lock("etcd_lock"):
File "/usr/local/lib/python2.7/dist-packages/etcd3/locks.py", line 136, in __enter__
self.acquire()
File "/usr/local/lib/python2.7/dist-packages/etcd3/locks.py", line 103, in acquire
return _acquire()
File "/usr/local/lib/python2.7/dist-packages/tenacity/__init__.py", line 231, in wrapped_f
return self.call(f, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/tenacity/__init__.py", line 313, in call
start_time=start_time)
File "/usr/local/lib/python2.7/dist-packages/tenacity/__init__.py", line 269, in iter
return fut.result()
File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/_base.py", line 455, in result
return self.__get_result()
File "/usr/local/lib/python2.7/dist-packages/tenacity/__init__.py", line 316, in call
result = fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/etcd3/locks.py", line 83, in _acquire
self.lease = self.etcd_client.lease(self.ttl)
File "/usr/local/lib/python2.7/dist-packages/etcd3/client.py", line 48, in handler
_translate_exception(exc)
File "/usr/local/lib/python2.7/dist-packages/etcd3/client.py", line 32, in _translate_exception
raise exception
ConnectionFailedError
```

Contributor guide

Open the contributing guide

Research direction

Start with the reported 10-thread reproduction and inspect etcd3/locks.py, especially acquire and _acquire, then follow the exception translation in etcd3/client.py. Determine why waiting threads can raise ConnectionFailedError and verify that the concurrent lock scenario no longer produces the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.