diff options
author | Jan Lindström <jplindst@mariadb.org> | 2014-07-25 10:30:16 +0300 |
---|---|---|
committer | Jan Lindström <jplindst@mariadb.org> | 2014-07-25 10:30:16 +0300 |
commit | a3acd725704c99dcb8a7a0d0c7c47e43c33a6cd7 (patch) | |
tree | b980bdd63882167d23c4e03efff065af615cd88a /storage/innobase/sync | |
parent | 6192f0bffa798c01acc85db9f427ed02234aead4 (diff) | |
download | mariadb-git-a3acd725704c99dcb8a7a0d0c7c47e43c33a6cd7.tar.gz |
Merge InnoDB fixes from 5.5 revisions 4229, 4230, 4233, 4237 and 4238 i.e.
4229: MDEV-5670: Assertion failure in file buf0lru.c line 2355
Add more status information if repeatable.
4230: MDEV-5673: Crash while parallel dropping multiple tables under heavy load
Improve long semaphore wait output to include all semaphore waits
and try to find out if there is a sequence of waiters.
4233: Fix compiler errors on product build.
4237: Fix too agressive long semaphore wait output and add guard against introducing
compression failures on insert buffer.
4238: Fix test failure caused by simulated compression failure on
IBUF_DUMMY table.
Diffstat (limited to 'storage/innobase/sync')
-rw-r--r-- | storage/innobase/sync/sync0arr.cc | 120 |
1 files changed, 87 insertions, 33 deletions
diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc index 8e1b8180eb1..82eac41cef9 100644 --- a/storage/innobase/sync/sync0arr.cc +++ b/storage/innobase/sync/sync0arr.cc @@ -182,6 +182,33 @@ sync_array_get_nth_cell( } /******************************************************************//** +Looks for a cell with the given thread id. +@return pointer to cell or NULL if not found */ +static +sync_cell_t* +sync_array_find_thread( +/*===================*/ + sync_array_t* arr, /*!< in: wait array */ + os_thread_id_t thread) /*!< in: thread id */ +{ + ulint i; + sync_cell_t* cell; + + for (i = 0; i < arr->n_cells; i++) { + + cell = sync_array_get_nth_cell(arr, i); + + if (cell->wait_object != NULL + && os_thread_eq(cell->thread, thread)) { + + return(cell); /* Found */ + } + } + + return(NULL); /* Not found */ +} + +/******************************************************************//** Reserves the mutex semaphore protecting a sync array. */ static void @@ -432,8 +459,10 @@ static void sync_array_cell_print( /*==================*/ - FILE* file, /*!< in: file where to print */ - sync_cell_t* cell) /*!< in: sync cell */ + FILE* file, /*!< in: file where to print */ + sync_cell_t* cell, /*!< in: sync cell */ + os_thread_id_t* reserver) /*!< out: write reserver or + 0 */ { ib_mutex_t* mutex; rw_lock_t* rwlock; @@ -494,6 +523,7 @@ sync_array_cell_print( writer == RW_LOCK_EX ? " exclusive\n" : " wait exclusive\n"); + *reserver = rwlock->writer_thread; } fprintf(file, @@ -519,32 +549,6 @@ sync_array_cell_print( } #ifdef UNIV_SYNC_DEBUG -/******************************************************************//** -Looks for a cell with the given thread id. -@return pointer to cell or NULL if not found */ -static -sync_cell_t* -sync_array_find_thread( -/*===================*/ - sync_array_t* arr, /*!< in: wait array */ - os_thread_id_t thread) /*!< in: thread id */ -{ - ulint i; - sync_cell_t* cell; - - for (i = 0; i < arr->n_cells; i++) { - - cell = sync_array_get_nth_cell(arr, i); - - if (cell->wait_object != NULL - && os_thread_eq(cell->thread, thread)) { - - return(cell); /* Found */ - } - } - - return(NULL); /* Not found */ -} /******************************************************************//** Recursion step for deadlock detection. @@ -606,6 +610,7 @@ sync_array_detect_deadlock( os_thread_id_t thread; ibool ret; rw_lock_debug_t*debug; + os_thread_id_t reserver=0; ut_a(arr); ut_a(start); @@ -641,10 +646,10 @@ sync_array_detect_deadlock( depth); if (ret) { fprintf(stderr, - "Mutex %p owned by thread %lu file %s line %lu\n", + "Mutex %p owned by thread %lu file %s line %lu\n", mutex, (ulong) os_thread_pf(mutex->thread_id), mutex->file_name, (ulong) mutex->line); - sync_array_cell_print(stderr, cell); + sync_array_cell_print(stderr, cell, &reserver); return(TRUE); } @@ -682,7 +687,7 @@ sync_array_detect_deadlock( print: fprintf(stderr, "rw-lock %p ", (void*) lock); - sync_array_cell_print(stderr, cell); + sync_array_cell_print(stderr, cell, &reserver); rw_lock_debug_print(stderr, debug); return(TRUE); } @@ -925,6 +930,7 @@ sync_array_print_long_waits_low( double diff; sync_cell_t* cell; void* wait_object; + os_thread_id_t reserver=0; cell = sync_array_get_nth_cell(arr, i); @@ -940,7 +946,7 @@ sync_array_print_long_waits_low( if (diff > SYNC_ARRAY_TIMEOUT) { fputs("InnoDB: Warning: a long semaphore wait:\n", stderr); - sync_array_cell_print(stderr, cell); + sync_array_cell_print(stderr, cell, &reserver); *noticed = TRUE; } @@ -955,6 +961,53 @@ sync_array_print_long_waits_low( } } + /* We found a long semaphore wait, wait all threads that are + waiting for a semaphore. */ + if (*noticed) { + for (i = 0; i < arr->n_cells; i++) { + void* wait_object; + os_thread_id_t reserver=0; + sync_cell_t* cell; + ulint loop = 0; + + cell = sync_array_get_nth_cell(arr, i); + + wait_object = cell->wait_object; + + if (wait_object == NULL || !cell->waiting) { + + continue; + } + + fputs("InnoDB: Warning: semaphore wait:\n", + stderr); + sync_array_cell_print(stderr, cell, &reserver); + + /* Try to output cell information for writer recursive way */ + while (reserver != 0) { + sync_cell_t* reserver_wait; + + reserver_wait = sync_array_find_thread(arr, reserver); + + if (reserver_wait && + reserver_wait->wait_object != NULL && + reserver_wait->waiting) { + fputs("InnoDB: Warning: Writer thread is waiting this semaphore:\n", + stderr); + sync_array_cell_print(stderr, reserver_wait, &reserver); + } else { + reserver = 0; + } + + /* This is protection against loop */ + if (loop > 100) { + fputs("InnoDB: Warning: Too many waiting threads.\n", stderr); + break; + } + } + } + } + #undef SYNC_ARRAY_TIMEOUT return(fatal); @@ -1034,6 +1087,7 @@ sync_array_print_info_low( { ulint i; ulint count = 0; + os_thread_id_t r = 0; fprintf(file, "OS WAIT ARRAY INFO: reservation count %ld\n", @@ -1046,7 +1100,7 @@ sync_array_print_info_low( if (cell->wait_object != NULL) { count++; - sync_array_cell_print(file, cell); + sync_array_cell_print(file, cell, &r); } } } |