Bug #77084 ib_table_truncate() doesn't release trx and cause hangup of shutdowning mysqld
Submitted: 19 May 2015 6:11 Modified: 25 May 2015 14:52
Reporter: Yasufumi Kinoshita Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7.7 OS:Any
Assigned to: CPU Architecture:Any

[19 May 2015 6:11] Yasufumi Kinoshita
Description:
This is bug of InnoDB API.

ib_table_truncate() doesn't release 'ib_trx' if (trunc_err != DB_SUCCESS).

The orphan ib_trx causes hangup at shutdown mysqld.

How to repeat:
call ib_table_truncate() for the table which doesn't exist, and shutdown mysqld.

Suggested fix:
=== modified file 'storage/innobase/api/api0api.cc'
--- storage/innobase/api/api0api.cc     2015-05-15 01:58:58 +0000
+++ storage/innobase/api/api0api.cc     2015-05-19 05:07:52 +0000
@@ -3285,13 +3289,14 @@ ib_table_truncate(
        if (trunc_err == DB_SUCCESS) {
                ut_a(!trx_is_started(static_cast<trx_t*>(ib_trx)));

-               err = ib_trx_release(ib_trx);
-               ut_a(err == DB_SUCCESS);
        } else {
                err = ib_trx_rollback(ib_trx);
                ut_a(err == DB_SUCCESS);
        }

+       err = ib_trx_release(ib_trx);
+       ut_a(err == DB_SUCCESS);
+
        /* Set the memcached_sync_count back. */
        if (table != NULL && memcached_sync != 0) {
                dict_mutex_enter_for_mysql();
[20 May 2015 13:44] MySQL Verification Team
This bug is verified solely by inspecting the source code.
[25 May 2015 14:52] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.6.26, 5.7.8, 5.8.0 releases, and here's the changelog entry:

The "ib_table_truncate" function failed to release a transaction,
resulting in a hang on server shutdown. 

Thank you for the bug report.