diff options
Diffstat (limited to 'storage/xtradb/srv/srv0srv.c')
-rw-r--r-- | storage/xtradb/srv/srv0srv.c | 109 |
1 files changed, 73 insertions, 36 deletions
diff --git a/storage/xtradb/srv/srv0srv.c b/storage/xtradb/srv/srv0srv.c index 71c2d79efd7..478fc0505bc 100644 --- a/storage/xtradb/srv/srv0srv.c +++ b/storage/xtradb/srv/srv0srv.c @@ -364,6 +364,9 @@ UNIV_INTERN ulint srv_conc_n_waiting_threads = 0; /* print all user-level transactions deadlocks to mysqld stderr */ UNIV_INTERN my_bool srv_print_all_deadlocks = FALSE; +/* Produce a stacktrace on long semaphore wait */ +UNIV_INTERN my_bool srv_use_stacktrace = FALSE; + typedef struct srv_conc_slot_struct srv_conc_slot_t; struct srv_conc_slot_struct{ os_event_t event; /*!< event to wait */ @@ -1278,8 +1281,10 @@ retry: os_thread_yield(); goto retry; } - if (trx->has_search_latch - || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) { + + ut_ad(!trx->has_search_latch); + + if (NULL != UT_LIST_GET_FIRST(trx->trx_locks)) { conc_n_threads = os_atomic_increment_lint(&srv_conc_n_threads, 1); enter_innodb_with_tickets(trx); @@ -1322,7 +1327,9 @@ srv_conc_enter_innodb( ulint sec; ulint ms; + ut_ad(!trx->has_search_latch); #ifdef UNIV_SYNC_DEBUG + ut_ad(!btr_search_own_any()); ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch)); #endif /* UNIV_SYNC_DEBUG */ @@ -1382,7 +1389,9 @@ retry: /* If the transaction is not holding resources, let it sleep for SRV_THREAD_SLEEP_DELAY microseconds, and try again then */ - if (!has_slept && !trx->has_search_latch + ut_ad(!trx->has_search_latch); + + if (!has_slept && NULL == UT_LIST_GET_FIRST(trx->trx_locks)) { has_slept = TRUE; /* We let it sleep only once to avoid @@ -1437,10 +1446,8 @@ retry: return; } - /* Release possible search system latch this thread has */ - if (trx->has_search_latch) { - trx_search_latch_release_if_reserved(trx); - } + /* No-op for XtraDB. */ + trx_search_latch_release_if_reserved(trx); /* Add to the queue */ slot->reserved = TRUE; @@ -1459,6 +1466,7 @@ retry: ut_ad(!trx->has_search_latch); #ifdef UNIV_SYNC_DEBUG + ut_ad(!btr_search_own_any()); ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch)); #endif /* UNIV_SYNC_DEBUG */ @@ -1510,7 +1518,9 @@ srv_conc_force_enter_innodb( trx_t* trx) /*!< in: transaction object associated with the thread */ { + ut_ad(!trx->has_search_latch); #ifdef UNIV_SYNC_DEBUG + ut_ad(!btr_search_own_any()); ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch)); #endif /* UNIV_SYNC_DEBUG */ @@ -1601,7 +1611,9 @@ srv_conc_force_exit_innodb( os_event_set(slot->event); } + ut_ad(!trx->has_search_latch); #ifdef UNIV_SYNC_DEBUG + ut_ad(!btr_search_own_any()); ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch)); #endif /* UNIV_SYNC_DEBUG */ } @@ -1615,7 +1627,9 @@ srv_conc_exit_innodb( trx_t* trx) /*!< in: transaction object associated with the thread */ { + ut_ad(!trx->has_search_latch); #ifdef UNIV_SYNC_DEBUG + ut_ad(!btr_search_own_any()); ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch)); #endif /* UNIV_SYNC_DEBUG */ @@ -1888,7 +1902,9 @@ srv_suspend_mysql_thread( os_event_wait(event); thd_wait_end(trx->mysql_thd); + ut_ad(!trx->has_search_latch); #ifdef UNIV_SYNC_DEBUG + ut_ad(!btr_search_own_any()); ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch)); #endif /* UNIV_SYNC_DEBUG */ @@ -2050,7 +2066,8 @@ srv_printf_innodb_monitor( ulint n_reserved; ibool ret; - ulint btr_search_sys_subtotal; + ulong btr_search_sys_constant; + ulong btr_search_sys_variable; ulint lock_sys_subtotal; ulint recv_sys_subtotal; @@ -2116,7 +2133,7 @@ srv_printf_innodb_monitor( ibuf_print(file); for (i = 0; i < btr_search_index_num; i++) { - ha_print_info(file, btr_search_get_hash_index((index_id_t)i)); + ha_print_info(file, btr_search_sys->hash_tables[i]); } fprintf(file, @@ -2144,16 +2161,28 @@ srv_printf_innodb_monitor( fprintf(file, "Total memory allocated by read views " ULINTPF "\n", srv_read_views_memory); - /* Calcurate reserved memories */ - if (btr_search_sys && btr_search_sys->hash_index[0]->heap) { - btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index[0]->heap); - } else { - btr_search_sys_subtotal = 0; - for (i=0; i < btr_search_sys->hash_index[0]->n_mutexes; i++) { - btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index[0]->heaps[i]); - } + + /* Calculate AHI constant and variable memory allocations */ + + btr_search_sys_constant = 0; + btr_search_sys_variable = 0; + + ut_ad(btr_search_sys->hash_tables); + + for (i = 0; i < btr_search_index_num; i++) { + hash_table_t* ht = btr_search_sys->hash_tables[i]; + + ut_ad(ht); + ut_ad(ht->heap); + + /* Multiple mutexes/heaps are currently never used for adaptive + hash index tables. */ + ut_ad(!ht->n_mutexes); + ut_ad(!ht->heaps); + + btr_search_sys_variable += mem_heap_get_size(ht->heap); + btr_search_sys_constant += ht->n_cells * sizeof(hash_cell_t); } - btr_search_sys_subtotal *= btr_search_index_num; lock_sys_subtotal = 0; if (trx_sys) { @@ -2178,12 +2207,9 @@ srv_printf_innodb_monitor( " Lock system %lu \t(%lu + %lu)\n" " Recovery system %lu \t(%lu + %lu)\n", - (ulong) (btr_search_sys - ? (btr_search_sys->hash_index[0]->n_cells * btr_search_index_num * sizeof(hash_cell_t)) : 0) - + btr_search_sys_subtotal, - (ulong) (btr_search_sys - ? (btr_search_sys->hash_index[0]->n_cells * btr_search_index_num * sizeof(hash_cell_t)) : 0), - (ulong) btr_search_sys_subtotal, + btr_search_sys_constant + btr_search_sys_variable, + btr_search_sys_constant, + btr_search_sys_variable, (ulong) (buf_pool_from_array(0)->page_hash->n_cells * sizeof(hash_cell_t)), @@ -2345,17 +2371,22 @@ srv_export_innodb_status(void) buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len); buf_get_total_list_size_in_bytes(&buf_pools_list_size); - if (btr_search_sys && btr_search_sys->hash_index[0]->heap) { - mem_adaptive_hash = mem_heap_get_size(btr_search_sys->hash_index[0]->heap); - } else { - mem_adaptive_hash = 0; - for (i=0; i < btr_search_sys->hash_index[0]->n_mutexes; i++) { - mem_adaptive_hash += mem_heap_get_size(btr_search_sys->hash_index[0]->heaps[i]); - } - } - mem_adaptive_hash *= btr_search_index_num; - if (btr_search_sys) { - mem_adaptive_hash += (btr_search_sys->hash_index[0]->n_cells * btr_search_index_num * sizeof(hash_cell_t)); + mem_adaptive_hash = 0; + + ut_ad(btr_search_sys->hash_tables); + + for (i = 0; i < btr_search_index_num; i++) { + hash_table_t* ht = btr_search_sys->hash_tables[i]; + + ut_ad(ht); + ut_ad(ht->heap); + /* Multiple mutexes/heaps are currently never used for adaptive + hash index tables. */ + ut_ad(!ht->n_mutexes); + ut_ad(!ht->heaps); + + mem_adaptive_hash += mem_heap_get_size(ht->heap); + mem_adaptive_hash += ht->n_cells * sizeof(hash_cell_t); } mem_dictionary = (dict_sys ? ((dict_sys->table_hash->n_cells @@ -2368,7 +2399,7 @@ srv_export_innodb_status(void) export_vars.innodb_adaptive_hash_cells = 0; export_vars.innodb_adaptive_hash_heap_buffers = 0; for (i = 0; i < btr_search_index_num; i++) { - hash_table_t* table = btr_search_get_hash_index((index_id_t)i); + hash_table_t* table = btr_search_sys->hash_tables[i]; export_vars.innodb_adaptive_hash_cells += hash_get_n_cells(table); @@ -3159,6 +3190,12 @@ srv_redo_log_follow_thread( os_event_wait(srv_checkpoint_completed_event); os_event_reset(srv_checkpoint_completed_event); +#ifdef UNIV_DEBUG + if (!srv_track_changed_pages) { + continue; + } +#endif + if (srv_shutdown_state < SRV_SHUTDOWN_LAST_PHASE) { if (!log_online_follow_redo_log()) { /* TODO: sync with I_S log tracking status? */ |