#At file:///home/marko/innobase/dev/mysql2a/5.5-innodb/ based on revid:vasil.dimov@strippedcvryhj7ci91
3353 Marko Mäkelä 2011-03-30 [merge]
Merge mysql-5.1-innodb to mysql-5.5-innodb.
modified:
storage/innobase/include/sync0arr.h
storage/innobase/srv/srv0srv.c
storage/innobase/sync/sync0arr.c
=== modified file 'storage/innobase/include/sync0arr.h'
--- a/storage/innobase/include/sync0arr.h revid:vasil.dimov@stripped
+++ b/storage/innobase/include/sync0arr.h revid:marko.makela@oracle.com-20110330115226-vlbyawb3dy2dtl9a
@@ -115,8 +115,11 @@ Prints warnings of long semaphore waits
@return TRUE if fatal semaphore wait threshold was exceeded */
UNIV_INTERN
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
that the number of reserved cells equals the count variable. */
=== modified file 'storage/innobase/srv/srv0srv.c'
--- a/storage/innobase/srv/srv0srv.c revid:vasil.dimov@stripped4eqcvryhj7ci91
+++ b/storage/innobase/srv/srv0srv.c revid:marko.makela@stripped
@@ -2367,6 +2367,12 @@ srv_error_monitor_thread(
ib_uint64_t old_lsn;
ib_uint64_t new_lsn;
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;
@@ -2420,7 +2426,8 @@ loop:
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++;
if (fatal_cnt > 10) {
@@ -2435,6 +2442,8 @@ loop:
}
} else {
fatal_cnt = 0;
+ old_waiter = waiter;
+ old_sema = sema;
}
/* Flush stderr so that a database user gets the output
=== modified file 'storage/innobase/sync/sync0arr.c'
--- a/storage/innobase/sync/sync0arr.c revid:vasil.dimov@stripped534eqcvryhj7ci91
+++ b/storage/innobase/sync/sync0arr.c revid:marko.makela@strippedl9a
@@ -915,8 +915,10 @@ Prints warnings of long semaphore waits
@return TRUE if fatal semaphore wait threshold was exceeded */
UNIV_INTERN
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;
ibool old_val;
@@ -924,6 +926,7 @@ sync_array_print_long_waits(void)
ulint i;
ulint fatal_timeout = srv_fatal_semaphore_wait_threshold;
ibool fatal = FALSE;
+ double longest_diff = 0;
#ifdef UNIV_DEBUG_VALGRIND
/* Increase the timeouts if running under valgrind because it executes
@@ -939,22 +942,36 @@ sync_array_print_long_waits(void)
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);
- if (cell->wait_object != NULL && cell->waiting
- && difftime(time(NULL), cell->reservation_time)
- > SYNC_ARRAY_TIMEOUT) {
+ wait_object = cell->wait_object;
+
+ 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",
stderr);
sync_array_cell_print(stderr, cell);
noticed = TRUE;
}
- if (cell->wait_object != NULL && cell->waiting
- && difftime(time(NULL), cell->reservation_time)
- > fatal_timeout) {
+ if (diff > fatal_timeout) {
fatal = TRUE;
}
+
+ if (diff > longest_diff) {
+ longest_diff = diff;
+ *sema = wait_object;
+ *waiter = cell->thread;
+ }
}
if (noticed) {
Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110330115226-vlbyawb3dy2dtl9a.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5-innodb branch (marko.makela:3353) | marko.makela | 30 Mar |