>From dispatch_command() in sql_parse.cc net_end_statement() is called after ha_autocommit_or_rollback() but before close_thread_tables(). What can go wrong in the call to close_thread_tables() after the response to the client? Commit or rollback was done before a response was sent to the client.

  /* If commit fails, we should be able to reset the OK status. */
  thd->main_da.can_overwrite_status= TRUE;
  ha_autocommit_or_rollback(thd, thd->is_error());
  thd->main_da.can_overwrite_status= FALSE;

  thd->transaction.stmt.reset();

  net_end_statement(thd);
  query_cache_end_of_result(thd);

  thd->proc_info= "closing tables";
  /* Free tables */
  close_thread_tables(thd);



--
Mark Callaghan
mdcallag@gmail.com