Skip to content

Commit

Permalink
#83 Release lock before commit_order_enter()
Browse files Browse the repository at this point in the history
A high priority transaction T2 which calls commit_order_enter() with
client_state mutex locked may cause a deadlock if an another high
priority transaction T1 ordered before tries to access the transaction
T2 state.

As a fix, make sure that commit_order_enter() is never called with
client_state mutex locked.
  • Loading branch information
temeo committed Feb 18, 2019
1 parent 8c2daa7 commit 92024c7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ int wsrep::transaction::before_commit()
{
ret = 0;
}
lock.unlock();
ret = ret || provider().commit_order_enter(ws_handle_, ws_meta_);
lock.lock();
if (ret)
{
state(lock, s_must_abort);
Expand Down Expand Up @@ -749,7 +751,9 @@ int wsrep::transaction::after_statement()
{
if (ordered())
{
lock.unlock();
ret = provider().commit_order_enter(ws_handle_, ws_meta_);
lock.lock();
if (ret == 0)
{
provider().commit_order_leave(ws_handle_, ws_meta_);
Expand Down Expand Up @@ -785,7 +789,9 @@ void wsrep::transaction::after_applying()
// been done.
if (state_ == s_aborted && ordered())
{
lock.unlock();
int ret(provider().commit_order_enter(ws_handle_, ws_meta_));
lock.lock();
if (ret == 0)
{
provider().commit_order_leave(ws_handle_, ws_meta_);
Expand Down

0 comments on commit 92024c7

Please sign in to comment.