Bug#16513588:"PREPARE_COMMIT_MUTEX" IS NOT FREED DURING TRANSACTION ROLLBACK
Bug#16513588:"PREPARE_COMMIT_MUTEX" IS NOT FREED DURING
TRANSACTION ROLLBACK

Problem:
=======
"prepare_commit_mutex" is acquired during "innobase_xa_prepare"
and it is freed only in "innobase_commit". After prepare,
if the commit operation fails the transaction is rolled back
but the mutex is not released.

Analysis:
========
During transaction commit process transaction is prepared and
the "prepare_commit_mutex" is acquired to preserve the order
of commit. After prepare write to binlog is initiated.

File: sql/handler.cc
      if (error || (is_real_trans && xid &&
----->             (error= !(cookie= tc_log->log_xid(thd, xid)))))
      {
        ha_rollback_trans(thd, all);

In the above code "tc_log->log_xid" operation fails.

When the write to binlog fails the transaction is rolled back
with out freeing the mutex. A subsequent "INSERT" operation
tries to acquire the same mutex during its commit process
and the server aborts.

Fix:
===
"prepare_commit_mutex" is freed during "innobase_rollback".
davidl-zend/zenddbi,flynn1973/mariadb-aix,ollie314/server,davidl-zend/zenddbi,davidl-zend/zenddbi,ollie314/server,natsys/mariadb_10.2,ollie314/server,flynn1973/mariadb-aix,ollie314/server,ollie314/server,natsys/mariadb_10.2,natsys/mariadb_10.2,ollie314/server,ollie314/server,natsys/mariadb_10.2,ollie314/server,flynn1973/mariadb-aix,flynn1973/mariadb-aix,flynn1973/mariadb-aix,flynn1973/mariadb-aix,davidl-zend/zenddbi,davidl-zend/zenddbi,natsys/mariadb_10.2,flynn1973/mariadb-aix,davidl-zend/zenddbi,natsys/mariadb_10.2,flynn1973/mariadb-aix,davidl-zend/zenddbi,ollie314/server,davidl-zend/zenddbi,ollie314/server,ollie314/server,davidl-zend/zenddbi,natsys/mariadb_10.2,flynn1973/mariadb-aix,natsys/mariadb_10.2,slanterns/server,flynn1973/mariadb-aix,natsys/mariadb_10.2,davidl-zend/zenddbi,natsys/mariadb_10.2,flynn1973/mariadb-aix,natsys/mariadb_10.2,davidl-zend/zenddbi