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
For Gerrit Dashboard: MB-19222 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
62911,4 | MB-19222: Fix race condition in TaskQueue shutdown | 3.0.x | ep-engine | Status: MERGED | +2 | +1 |
64980,2 | Merge remote-tracking branch 'couchbase/3.0.x' into sherlock | sherlock | ep-engine | Status: MERGED | +2 | +1 |
66010,3 | Merge commit 'couchbase/sherlock' into 'couchbase/watson' | watson | ep-engine | Status: ABANDONED | 0 | -1 |
66054,6 | Merge remote-tracking branch 'couchbase/sherlock' into 'couchbase/watson' | watson | ep-engine | Status: MERGED | +2 | +1 |