Index: handler/ha_innodb.cc =================================================================== --- handler/ha_innodb.cc (revision 2009) +++ handler/ha_innodb.cc (working copy) @@ -351,6 +351,12 @@ /*========================*/ trx_t* trx) /* in: transaction handle */ { + THD* thd; + thd = current_thd; // avoid calling current_thd twice, it may be slow + if (thd != NULL && thd->status_var.created_tmp_disk_tables) { + innobase_release_temporary_latches(thd); + } + if (UNIV_LIKELY(!srv_thread_concurrency)) { return;