Details
-
Bug
-
Resolution: Fixed
-
Major
-
3.1.4
-
Untriaged
-
Unknown
-
KV: April 13 - April 26
Description
There is a bug in the use of ExecutorThread.state when sleeping a TaskQueue - TaskQueue::_doSleep() doesn't atomically transition the state from RUNNING -> SLEEPING. This can cause a deadlock when shutting down a ExecutorThread:
|
Thread A: Thread B:
|
-------------------------------- ------------------------------
|
if (t.state == RUNNING) { // true
|
t.state = SHUTDOWN
|
t.state = SLEEPING cb_join_thread(Thread A)
|
// wait forever
|
...
|
if (t.state == SHUTDOWN) { // FALSE
|
exit(0) // NEVER REACHED
|
}
|
Fix by changing ExecutorThread.state to be an AtomicValue, and use compare-and-exchange to move from RUNNING -> SLEEPING (and SLEEPING -> RUNNING).
Note: This was previously fixed in 4.0.0 prior to release - see http://review.couchbase.org/43134 Backporting as 3.x ThreadSanitizer runs have flagged it as an issue there also.
Attachments
Issue Links
- blocks
-
MB-19323 3.1.6 release
- Closed