| 1700 | /* Do operations that may take a long time */ |
| 1701 | |
| 1702 | void THD::cleanup(void) |
| 1703 | { |
| 1704 | DBUG_ENTER("THD::cleanup"); |
| 1705 | DBUG_ASSERT(cleanup_done == 0); |
| 1706 | |
| 1707 | set_killed(KILL_CONNECTION); |
| 1708 | #ifdef WITH_WSREP |
| 1709 | if (wsrep_cs().state() != wsrep::client_state::s_none) |
| 1710 | wsrep_cs().cleanup(); |
| 1711 | wsrep_client_thread= false; |
| 1712 | #endif /* WITH_WSREP */ |
| 1713 | |
| 1714 | DEBUG_SYNC(this, "THD_cleanup_after_set_killed"); |
| 1715 | |
| 1716 | mysql_ha_cleanup(this); |
| 1717 | locked_tables_list.unlock_locked_tables(this); |
| 1718 | |
| 1719 | delete_dynamic(&user_var_events); |
| 1720 | close_temporary_tables(); |
| 1721 | |
| 1722 | if (transaction->xid_state.is_explicit_XA()) |
| 1723 | trans_xa_detach(this); |
| 1724 | else |
| 1725 | trans_rollback(this); |
| 1726 | |
| 1727 | DEBUG_SYNC(this, "THD_cleanup_after_trans_cleanup"); |
| 1728 | |
| 1729 | DBUG_ASSERT(open_tables == NULL); |
| 1730 | DBUG_ASSERT(m_transaction_psi == NULL); |
| 1731 | |
| 1732 | /* |
| 1733 | If the thread was in the middle of an ongoing transaction (rolled |
| 1734 | back a few lines above) or under LOCK TABLES (unlocked the tables |
| 1735 | and left the mode a few lines above), there will be outstanding |
| 1736 | metadata locks. Release them. |
| 1737 | */ |
| 1738 | mdl_context.release_transactional_locks(this); |
| 1739 | |
| 1740 | backup_end(this); |
| 1741 | backup_unlock(this); |
| 1742 | |
| 1743 | /* Release the global read lock, if acquired. */ |
| 1744 | if (global_read_lock.is_acquired()) |
| 1745 | global_read_lock.unlock_global_read_lock(this); |
| 1746 | |
| 1747 | if (user_connect) |
| 1748 | { |
| 1749 | decrease_user_connections(user_connect); |
| 1750 | user_connect= 0; // Safety |
| 1751 | } |
| 1752 | wt_thd_destroy(&transaction->wt); |
| 1753 | |
| 1754 | my_hash_free(&user_vars); |
| 1755 | my_hash_free(&sequences); |
| 1756 | sp_caches_clear(); |
| 1757 | statement_rcontext_reinit(); |
| 1758 | auto_inc_intervals_forced.empty(); |
| 1759 | auto_inc_intervals_in_cur_stmt_for_binlog.empty(); |
nothing calls this directly
no test coverage detected