OpenStack library for all concurrency-related code
Go to file
Balazs Gibizer 796203c948 Prove that spawn_n with fair lock is broken
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
2022-09-05 13:27:37 +02:00
doc Remove unnecessary unicode prefixes 2022-04-19 19:39:35 +08:00
oslo_concurrency Prove that spawn_n with fair lock is broken 2022-09-05 13:27:37 +02:00
releasenotes Merge "Fix formatting of release list" 2022-07-14 11:56:56 +00:00
.coveragerc Fix coverage configuration and execution 2015-10-05 17:01:16 -04:00
.gitignore ignore reno builds artifacts 2020-02-11 15:25:49 +01:00
.gitreview OpenDev Migration Patch 2019-04-19 19:28:07 +00:00
.mailmap exported from oslo-incubator by graduate.sh 2014-08-07 22:26:50 +04:00
.pre-commit-config.yaml Move flake8 as a pre-commit local target. 2021-03-23 13:15:24 +01:00
.stestr.conf Switch to stestr 2018-07-04 08:18:31 +07:00
.zuul.yaml Update CI to use unversioned jobs template 2022-03-15 15:07:07 +00:00
CONTRIBUTING.rst Align contributing doc with oslo's policy 2020-05-04 18:20:24 +02:00
HACKING.rst Update URLs in documents according to document migration 2017-07-12 22:22:54 +08:00
LICENSE exported from oslo-incubator by graduate.sh 2014-08-07 22:26:50 +04:00
README.rst Replace git.openstack.org URLs with opendev.org URLs 2019-05-05 13:01:11 +08:00
requirements.txt Remove six usage 2020-05-09 16:42:30 +02:00
setup.cfg Drop python3.6/3.7 support in testing runtime 2022-05-05 16:10:49 +02:00
setup.py remove outdated header 2020-02-10 18:34:51 +01:00
test-requirements.txt Adding pre-commit 2020-09-03 14:25:24 +02:00
tox.ini Prove that spawn_n with fair lock is broken 2022-09-05 13:27:37 +02:00

README.rst

Team and repository tags

image

oslo.concurrency

Latest Version

The oslo.concurrency library has utilities for safely running multi-thread, multi-process applications using locking mechanisms and for running external processes.