From: Xiaoxi Chen Date: Wed, 29 Apr 2015 05:59:16 +0000 (+0800) Subject: os/newstore: fix deadlock when newstore_sync_transaction=true X-Git-Tag: v9.1.0~242^2~29 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e3abf245ba4a555b695a437fa488ca41b36c2c77;p=ceph.git os/newstore: fix deadlock when newstore_sync_transaction=true There is a deadlock issue in Newstore when newstore_sync_transaction = true. With sync_transaction to true, the txc state machine will go all the way down from STATE_IO_DONE to STATE_FINISHING in the same thread, while holding the osr->qlock(). The deadlock is caused in _txc_finish and _osr_reap_done, when trying to lock osr->qlock again. Since the _txc_finish can be called with(in sync transaction mode) or without (in async transaction mode) holding the qlock, so fix this by setting the qlock to PTHREAD_MUTEX_RECURSIVE, thus we can recursive acquire the qlock. Signed-off-by: Xiaoxi Chen --- diff --git a/src/os/newstore/NewStore.h b/src/os/newstore/NewStore.h index 95122a1c4662..c126873e970e 100644 --- a/src/os/newstore/NewStore.h +++ b/src/os/newstore/NewStore.h @@ -279,7 +279,8 @@ public: Mutex wal_apply_lock; OpSequencer() - : qlock("NewStore::OpSequencer::qlock", false, false), + //set the qlock to to PTHREAD_MUTEX_RECURSIVE mode + : qlock("NewStore::OpSequencer::qlock", true, false), parent(NULL), wal_apply_lock("NewStore::OpSequencer::wal_apply_lock") { }