Commit a3bf31d8 authored by marko's avatar marko

branches/zip: Merge a change from MySQL:

------------------------------------------------------------
revno: 3236
committer: Satya B <satya.bn@sun.com>
branch nick: mysql-5.1-bugteam
timestamp: Tue 2009-12-01 17:48:57 +0530
message:
  merge to mysql-5.1-bugteam
    ------------------------------------------------------------
    revno: 3234.1.1
    committer: Gleb Shchepa <gshchepa@mysql.com>
    branch nick: mysql-5.1-bugteam
    timestamp: Tue 2009-12-01 14:38:40 +0400
    message:
      Bug #38883 (reopened): thd_security_context is not thread safe, crashes?

      manual merge 5.0-->5.1, updating InnoDB plugin.
    ------------------------------------------------------------
    revno: 1810.3968.13
    committer: Gleb Shchepa <gshchepa@mysql.com>
    branch nick: mysql-5.0-bugteam
    timestamp: Tue 2009-12-01 14:24:44 +0400
    message:
      Bug #38883 (reopened): thd_security_context is not thread safe, crashes?

      The bug 38816 changed the lock that protects THD::query from
      LOCK_thread_count to LOCK_thd_data, but didn't update the associated
      InnoDB functions.

      1. The innobase_mysql_prepare_print_arbitrary_thd and the
      innobase_mysql_end_print_arbitrary_thd InnoDB functions have been
      removed, since now we have a per-thread mutex: now we don't need to wrap
      several inter-thread access tries to THD::query with a single global
      LOCK_thread_count lock, so we can simplify the code.

      2. The innobase_mysql_print_thd function has been modified to lock
      LOCK_thd_data in direct way.
parent 36e83aca
...@@ -898,36 +898,6 @@ convert_error_code_to_mysql( ...@@ -898,36 +898,6 @@ convert_error_code_to_mysql(
} }
} }
/*************************************************************//**
If you want to print a thd that is not associated with the current thread,
you must call this function before reserving the InnoDB kernel_mutex, to
protect MySQL from setting thd->query NULL. If you print a thd of the current
thread, we know that MySQL cannot modify thd->query, and it is not necessary
to call this. Call innobase_mysql_end_print_arbitrary_thd() after you release
the kernel_mutex. */
extern "C" UNIV_INTERN
void
innobase_mysql_prepare_print_arbitrary_thd(void)
/*============================================*/
{
ut_ad(!mutex_own(&kernel_mutex));
VOID(pthread_mutex_lock(&LOCK_thread_count));
}
/*************************************************************//**
Releases the mutex reserved by innobase_mysql_prepare_print_arbitrary_thd().
In the InnoDB latching order, the mutex sits right above the
kernel_mutex. In debug builds, we assert that the kernel_mutex is
released before this function is invoked. */
extern "C" UNIV_INTERN
void
innobase_mysql_end_print_arbitrary_thd(void)
/*========================================*/
{
ut_ad(!mutex_own(&kernel_mutex));
VOID(pthread_mutex_unlock(&LOCK_thread_count));
}
/*************************************************************//** /*************************************************************//**
Prints info of a THD object (== user session thread) to the given file. */ Prints info of a THD object (== user session thread) to the given file. */
extern "C" UNIV_INTERN extern "C" UNIV_INTERN
......
...@@ -153,28 +153,6 @@ get_innobase_type_from_mysql_type( ...@@ -153,28 +153,6 @@ get_innobase_type_from_mysql_type(
const void* field) /*!< in: MySQL Field */ const void* field) /*!< in: MySQL Field */
__attribute__((nonnull)); __attribute__((nonnull));
/*************************************************************//**
If you want to print a thd that is not associated with the current thread,
you must call this function before reserving the InnoDB kernel_mutex, to
protect MySQL from setting thd->query NULL. If you print a thd of the current
thread, we know that MySQL cannot modify thd->query, and it is not necessary
to call this. Call innobase_mysql_end_print_arbitrary_thd() after you release
the kernel_mutex. */
UNIV_INTERN
void
innobase_mysql_prepare_print_arbitrary_thd(void);
/*============================================*/
/*************************************************************//**
Releases the mutex reserved by innobase_mysql_prepare_print_arbitrary_thd().
In the InnoDB latching order, the mutex sits right above the
kernel_mutex. In debug builds, we assert that the kernel_mutex is
released before this function is invoked. */
UNIV_INTERN
void
innobase_mysql_end_print_arbitrary_thd(void);
/*========================================*/
/******************************************************************//** /******************************************************************//**
Get the variable length bounds of the given character set. */ Get the variable length bounds of the given character set. */
UNIV_INTERN UNIV_INTERN
......
...@@ -338,9 +338,7 @@ trx_commit_step( ...@@ -338,9 +338,7 @@ trx_commit_step(
/**********************************************************************//** /**********************************************************************//**
Prints info about a transaction to the given file. The caller must own the Prints info about a transaction to the given file. The caller must own the
kernel mutex and must have called kernel mutex. */
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
or InnoDB cannot meanwhile change the info printed here. */
UNIV_INTERN UNIV_INTERN
void void
trx_print( trx_print(
......
...@@ -4324,11 +4324,6 @@ lock_print_info_summary( ...@@ -4324,11 +4324,6 @@ lock_print_info_summary(
/*====================*/ /*====================*/
FILE* file) /*!< in: file where to print */ FILE* file) /*!< in: file where to print */
{ {
/* We must protect the MySQL thd->query field with a MySQL mutex, and
because the MySQL mutex must be reserved before the kernel_mutex of
InnoDB, we call innobase_mysql_prepare_print_arbitrary_thd() here. */
innobase_mysql_prepare_print_arbitrary_thd();
lock_mutex_enter_kernel(); lock_mutex_enter_kernel();
if (lock_deadlock_found) { if (lock_deadlock_found) {
...@@ -4411,7 +4406,6 @@ lock_print_info_all_transactions( ...@@ -4411,7 +4406,6 @@ lock_print_info_all_transactions(
if (trx == NULL) { if (trx == NULL) {
lock_mutex_exit_kernel(); lock_mutex_exit_kernel();
innobase_mysql_end_print_arbitrary_thd();
ut_ad(lock_validate()); ut_ad(lock_validate());
...@@ -4495,7 +4489,6 @@ lock_print_info_all_transactions( ...@@ -4495,7 +4489,6 @@ lock_print_info_all_transactions(
} }
lock_mutex_exit_kernel(); lock_mutex_exit_kernel();
innobase_mysql_end_print_arbitrary_thd();
mtr_start(&mtr); mtr_start(&mtr);
...@@ -4506,7 +4499,6 @@ lock_print_info_all_transactions( ...@@ -4506,7 +4499,6 @@ lock_print_info_all_transactions(
load_page_first = FALSE; load_page_first = FALSE;
innobase_mysql_prepare_print_arbitrary_thd();
lock_mutex_enter_kernel(); lock_mutex_enter_kernel();
goto loop; goto loop;
......
...@@ -1205,9 +1205,6 @@ trx_i_s_possibly_fetch_data_into_cache( ...@@ -1205,9 +1205,6 @@ trx_i_s_possibly_fetch_data_into_cache(
return(1); return(1);
} }
/* We are going to access trx->query in all transactions */
innobase_mysql_prepare_print_arbitrary_thd();
/* We need to read trx_sys and record/table lock queues */ /* We need to read trx_sys and record/table lock queues */
mutex_enter(&kernel_mutex); mutex_enter(&kernel_mutex);
...@@ -1215,8 +1212,6 @@ trx_i_s_possibly_fetch_data_into_cache( ...@@ -1215,8 +1212,6 @@ trx_i_s_possibly_fetch_data_into_cache(
mutex_exit(&kernel_mutex); mutex_exit(&kernel_mutex);
innobase_mysql_end_print_arbitrary_thd();
return(0); return(0);
} }
......
...@@ -1636,9 +1636,7 @@ trx_mark_sql_stat_end( ...@@ -1636,9 +1636,7 @@ trx_mark_sql_stat_end(
/**********************************************************************//** /**********************************************************************//**
Prints info about a transaction to the given file. The caller must own the Prints info about a transaction to the given file. The caller must own the
kernel mutex and must have called kernel mutex. */
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
or InnoDB cannot meanwhile change the info printed here. */
UNIV_INTERN UNIV_INTERN
void void
trx_print( trx_print(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment