[MDEV-7793] Race condition between XA COMMIT/ROLLBACK and disconnect Created: 2015-03-17  Updated: 2015-05-07  Resolved: 2015-05-07

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 5.5, 10.0, 10.1
Fix Version/s: 10.1.5

Type: Bug Priority: Major
Reporter: Sergey Vojtovich Assignee: Sergey Vojtovich
Resolution: Fixed Votes: 0
Labels: None


 Description   

Test case:

--source include/have_debug_sync.inc
 
# Note that this test is meaningful only with valgrind.
let $op= XA COMMIT 'xatest';
let $i= 2;
while ($i)
{
  connect con1, localhost, root;
  connect con2, localhost, root;
 
  connection con1;
  XA START 'xatest';
  XA END 'xatest';
  XA PREPARE 'xatest';
 
  connection con2;
  SET debug_sync='xa_after_search SIGNAL parked WAIT_FOR go';
  send_eval $op;
 
  connection default;
  SET debug_sync='now WAIT_FOR parked';
  disconnect con1;
  disable_query_log;
  echo # Waiting for thread to get deleted;
  while (`SELECT VARIABLE_VALUE!=2 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='max_used_connections'`)
  {
    real_sleep 0.1;
    FLUSH STATUS;
  }
  enable_query_log;
  SET debug_sync='now SIGNAL go';
 
  connection con2;
  --error ER_XAER_NOTA
  reap;
  disconnect con2;
 
  connection default;
  SET debug_sync='RESET';
 
  let $op= XA ROLLBACK 'xatest';
  dec $i;
}

Debug sync patch:

diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 3071ba6..5f744d5 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -5312,6 +5312,7 @@ XID_STATE *xid_cache_search(THD *thd, XID *xid)
   if (element)
   {
     lf_hash_search_unpin(thd->xid_hash_pins);
+    DEBUG_SYNC(current_thd, "xa_after_search");
     return element->m_xid_state;
   }
   return 0;



 Comments   
Comment by Sergey Vojtovich [ 2015-03-17 ]

serg, please review fix for this bug.

Generated at Thu Feb 08 07:22:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.