The ReaderWriterLock currently makes heavy use of
threading.current_thread to provide rentrancy.
the pattern in use either check if the pending writer is me or if the current acquire of the lock is the writer
however when used with eventlet and spawn_n that might return the python thread instead of the
eventlet greenthread id and allow different greenthread on the same OS thread to enter the critical section.
so as a result the ReaderWriterLock in all versions of fasteners after 0.15 is unsafe to use with eventlet if the calling application uses spawn_n. This usage may be indirect or explicit in the client application so they may not be aware of this.
The ReaderWriterLock currently makes heavy use of threading.current_thread to provide rentrancy.
the pattern in use either check if the pending writer is me or if the current acquire of the lock is the writer
however when used with eventlet and spawn_n that might return the python thread instead of the eventlet greenthread id and allow different greenthread on the same OS thread to enter the critical section.
we have reproduced this in nova and now oslo.cuncrraency https://review.opendev.org/c/openstack/oslo.concurrency/+/855713
it is likely because this workaround https://github.com/harlowja/fasteners/commit/467ed75ee1e9465ebff8b5edf452770befb93913 was removed in 0.15
when the issue was fixed in eventlet it did not cover all edge cases. https://github.com/eventlet/eventlet/issues/731
melanie noted that using spwan_n threading.current_thread() will return the native thread object. https://github.com/eventlet/eventlet/issues/731#issuecomment-969891721
so as a result the ReaderWriterLock in all versions of fasteners after 0.15 is unsafe to use with eventlet if the calling application uses spawn_n. This usage may be indirect or explicit in the client application so they may not be aware of this.