Commit fe347bbb authored by Marko Mäkelä's avatar Marko Mäkelä

Merge mysql-5.1-innodb to mysql-5.5-innodb.

parents 08bdd470 9a961662
...@@ -115,8 +115,11 @@ Prints warnings of long semaphore waits to stderr. ...@@ -115,8 +115,11 @@ Prints warnings of long semaphore waits to stderr.
@return TRUE if fatal semaphore wait threshold was exceeded */ @return TRUE if fatal semaphore wait threshold was exceeded */
UNIV_INTERN UNIV_INTERN
ibool ibool
sync_array_print_long_waits(void); sync_array_print_long_waits(
/*=============================*/ /*========================*/
os_thread_id_t* waiter, /*!< out: longest waiting thread */
const void** sema) /*!< out: longest-waited-for semaphore */
__attribute__((nonnull));
/********************************************************************//** /********************************************************************//**
Validates the integrity of the wait array. Checks Validates the integrity of the wait array. Checks
that the number of reserved cells equals the count variable. */ that the number of reserved cells equals the count variable. */
......
...@@ -2367,6 +2367,12 @@ srv_error_monitor_thread( ...@@ -2367,6 +2367,12 @@ srv_error_monitor_thread(
ib_uint64_t old_lsn; ib_uint64_t old_lsn;
ib_uint64_t new_lsn; ib_uint64_t new_lsn;
ib_int64_t sig_count; ib_int64_t sig_count;
/* longest waiting thread for a semaphore */
os_thread_id_t waiter = os_thread_get_curr_id();
os_thread_id_t old_waiter = waiter;
/* the semaphore that is being waited for */
const void* sema = NULL;
const void* old_sema = NULL;
old_lsn = srv_start_lsn; old_lsn = srv_start_lsn;
...@@ -2420,7 +2426,8 @@ srv_error_monitor_thread( ...@@ -2420,7 +2426,8 @@ srv_error_monitor_thread(
sync_arr_wake_threads_if_sema_free(); sync_arr_wake_threads_if_sema_free();
if (sync_array_print_long_waits()) { if (sync_array_print_long_waits(&waiter, &sema)
&& sema == old_sema && os_thread_eq(waiter, old_waiter)) {
fatal_cnt++; fatal_cnt++;
if (fatal_cnt > 10) { if (fatal_cnt > 10) {
...@@ -2435,6 +2442,8 @@ srv_error_monitor_thread( ...@@ -2435,6 +2442,8 @@ srv_error_monitor_thread(
} }
} else { } else {
fatal_cnt = 0; fatal_cnt = 0;
old_waiter = waiter;
old_sema = sema;
} }
/* Flush stderr so that a database user gets the output /* Flush stderr so that a database user gets the output
......
...@@ -915,8 +915,10 @@ Prints warnings of long semaphore waits to stderr. ...@@ -915,8 +915,10 @@ Prints warnings of long semaphore waits to stderr.
@return TRUE if fatal semaphore wait threshold was exceeded */ @return TRUE if fatal semaphore wait threshold was exceeded */
UNIV_INTERN UNIV_INTERN
ibool ibool
sync_array_print_long_waits(void) sync_array_print_long_waits(
/*=============================*/ /*========================*/
os_thread_id_t* waiter, /*!< out: longest waiting thread */
const void** sema) /*!< out: longest-waited-for semaphore */
{ {
sync_cell_t* cell; sync_cell_t* cell;
ibool old_val; ibool old_val;
...@@ -924,6 +926,7 @@ sync_array_print_long_waits(void) ...@@ -924,6 +926,7 @@ sync_array_print_long_waits(void)
ulint i; ulint i;
ulint fatal_timeout = srv_fatal_semaphore_wait_threshold; ulint fatal_timeout = srv_fatal_semaphore_wait_threshold;
ibool fatal = FALSE; ibool fatal = FALSE;
double longest_diff = 0;
#ifdef UNIV_DEBUG_VALGRIND #ifdef UNIV_DEBUG_VALGRIND
/* Increase the timeouts if running under valgrind because it executes /* Increase the timeouts if running under valgrind because it executes
...@@ -939,22 +942,36 @@ sync_array_print_long_waits(void) ...@@ -939,22 +942,36 @@ sync_array_print_long_waits(void)
for (i = 0; i < sync_primary_wait_array->n_cells; i++) { for (i = 0; i < sync_primary_wait_array->n_cells; i++) {
double diff;
void* wait_object;
cell = sync_array_get_nth_cell(sync_primary_wait_array, i); cell = sync_array_get_nth_cell(sync_primary_wait_array, i);
if (cell->wait_object != NULL && cell->waiting wait_object = cell->wait_object;
&& difftime(time(NULL), cell->reservation_time)
> SYNC_ARRAY_TIMEOUT) { if (wait_object == NULL || !cell->waiting) {
continue;
}
diff = difftime(time(NULL), cell->reservation_time);
if (diff > SYNC_ARRAY_TIMEOUT) {
fputs("InnoDB: Warning: a long semaphore wait:\n", fputs("InnoDB: Warning: a long semaphore wait:\n",
stderr); stderr);
sync_array_cell_print(stderr, cell); sync_array_cell_print(stderr, cell);
noticed = TRUE; noticed = TRUE;
} }
if (cell->wait_object != NULL && cell->waiting if (diff > fatal_timeout) {
&& difftime(time(NULL), cell->reservation_time)
> fatal_timeout) {
fatal = TRUE; fatal = TRUE;
} }
if (diff > longest_diff) {
longest_diff = diff;
*sema = wait_object;
*waiter = cell->thread;
}
} }
if (noticed) { if (noticed) {
......
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