796203c948
The fasteners lib in version 0.15.0 removed the
threading.current_thread workaround for eventlet[1] because eventlet
seemed to fixed the current_thread issues tracked in [2]. However the
fix for [2] only fixed half of the problem. The threading.current_thread
call works if it is called from thread created by eventlet.spawn.
However if the thread is created with eventlet.spawn_n then
threading.current_thread is still broken and returns the ID of the
python native thread.
The fasteners' ReaderWriterLock depends heavily on
threading.current_thread to decide which thread holds a lock and to
allow re-entry of that thread. This leads to the situation that
multiple threads created from spawn_n could take the same
ReaderWriterLock at the same time.
The fair internal lock in oslo.concurrency uses ReaderWriterLock and
as a result such lock is broken for threads created with spawn_n.
Note that this issue was raised with eventlet in [3] when the nova team
detected it via a direct usage of ReaderWriterLock in the nova test
code. As [3] did not lead to a solution in eventlet nova implemented a
nova local fix for the test code in [4].
However now we detected that oslo.concurrency is affected by this issue
as well.
This patch adds tests to show the scope of the problem.
Note that the coverage tox target is changed to explicitly enable native
threading otherwise it runs eventlet specific tests in a native
environment.
Also note that [5] was opened to reintroduce the workaround[1] in fasteners.
[1] 467ed75ee1
[2] https://github.com/eventlet/eventlet/issues/172
[3] https://github.com/eventlet/eventlet/issues/731
[4] https://review.opendev.org/c/openstack/nova/+/813114
[5] https://github.com/harlowja/fasteners/issues/96
Related-Bug: #1988311
Change-Id: Ibc193c855b49b95b46ebd2aac82ea89e33f885f0
58 lines
1.5 KiB
INI
58 lines
1.5 KiB
INI
[tox]
|
|
minversion = 3.2.0
|
|
envlist = py3,pep8
|
|
ignore_basepython_conflict = True
|
|
|
|
[testenv]
|
|
basepython = python3
|
|
deps =
|
|
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
|
-r{toxinidir}/test-requirements.txt
|
|
# We want to support both vanilla stdlib and eventlet monkey patched
|
|
whitelist_externals = env
|
|
commands =
|
|
env TEST_EVENTLET=0 lockutils-wrapper stestr run --slowest {posargs}
|
|
env TEST_EVENTLET=1 lockutils-wrapper stestr run --slowest {posargs}
|
|
|
|
[testenv:pep8]
|
|
deps = {[testenv]deps}
|
|
commands =
|
|
pre-commit run -a
|
|
# Run security linter
|
|
bandit -r oslo_concurrency -x tests -n5 --skip B311,B404,B603,B606
|
|
|
|
[testenv:venv]
|
|
commands = {posargs}
|
|
|
|
[testenv:docs]
|
|
whitelist_externals = rm
|
|
deps =
|
|
-c{env:TOX_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
|
|
-r{toxinidir}/doc/requirements.txt
|
|
commands =
|
|
rm -fr doc/build
|
|
sphinx-build -W --keep-going -b html doc/source doc/build/html {posargs}
|
|
|
|
[testenv:cover]
|
|
setenv =
|
|
PYTHON=coverage run --source oslo_concurrency --parallel-mode
|
|
commands =
|
|
env TEST_EVENTLET=0 lockutils-wrapper stestr run {posargs}
|
|
coverage combine
|
|
coverage html -d cover
|
|
coverage xml -o cover/coverage.xml
|
|
|
|
[flake8]
|
|
show-source = True
|
|
ignore = H405,W504
|
|
exclude=.venv,.git,.tox,dist,*lib/python*,*egg,build
|
|
|
|
[hacking]
|
|
import_exceptions =
|
|
oslo_concurrency._i18n
|
|
|
|
[testenv:releasenotes]
|
|
deps = {[testenv:docs]deps}
|
|
commands =
|
|
sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html
|