Skip to content

Commit

Permalink
Skip btr_search_latches[] in SHOW ENGINE INNODB STATUS
Browse files Browse the repository at this point in the history
ha_print_info(): Remove.

srv_printf_innodb_monitor(): Do not acquire btr_search_latches[]
Add the equivalent functionality that was part of the non-debug
version of ha_print_info().
  • Loading branch information
dr-m committed Dec 12, 2017
1 parent 86c6926 commit a3476a5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 68 deletions.
58 changes: 0 additions & 58 deletions storage/innobase/ha/ha0ha.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,62 +489,4 @@ ha_validate(
return(ok);
}
#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */

/*************************************************************//**
Prints info of a hash table. */
void
ha_print_info(
/*==========*/
FILE* file, /*!< in: file where to print */
hash_table_t* table) /*!< in: hash table */
{
#ifdef UNIV_DEBUG
/* Some of the code here is disabled for performance reasons in production
builds, see http://bugs.mysql.com/36941 */
#define PRINT_USED_CELLS
#endif /* UNIV_DEBUG */

#ifdef PRINT_USED_CELLS
hash_cell_t* cell;
ulint cells = 0;
ulint i;
#endif /* PRINT_USED_CELLS */
ulint n_bufs;

ut_ad(table);
ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
#ifdef PRINT_USED_CELLS
for (i = 0; i < hash_get_n_cells(table); i++) {

cell = hash_get_nth_cell(table, i);

if (cell->node) {

cells++;
}
}
#endif /* PRINT_USED_CELLS */

fprintf(file, "Hash table size %lu",
(ulong) hash_get_n_cells(table));

#ifdef PRINT_USED_CELLS
fprintf(file, ", used cells %lu", (ulong) cells);
#endif /* PRINT_USED_CELLS */

if (table->heaps == NULL && table->heap != NULL) {

/* This calculation is intended for the adaptive hash
index: how many buffer frames we have reserved? */

n_bufs = UT_LIST_GET_LEN(table->heap->base) - 1;

if (table->heap->free_block) {
n_bufs++;
}

fprintf(file, ", node heap has %lu buffer(s)\n",
(ulong) n_bufs);
}
}
#endif /* BTR_CUR_HASH_ADAPT */
7 changes: 0 additions & 7 deletions storage/innobase/include/ha0ha.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,6 @@ ha_validate(
ulint start_index, /*!< in: start index */
ulint end_index); /*!< in: end index */
#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */
/*************************************************************//**
Prints info of a hash table. */
void
ha_print_info(
/*==========*/
FILE* file, /*!< in: file where to print */
hash_table_t* table); /*!< in: hash table */

/** The hash table external chain node */
struct ha_node_t {
Expand Down
25 changes: 22 additions & 3 deletions storage/innobase/srv/srv0srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1323,9 +1323,28 @@ srv_printf_innodb_monitor(

#ifdef BTR_CUR_HASH_ADAPT
for (ulint i = 0; i < btr_ahi_parts; ++i) {
rw_lock_s_lock(btr_search_latches[i]);
ha_print_info(file, btr_search_sys->hash_tables[i]);
rw_lock_s_unlock(btr_search_latches[i]);
const hash_table_t* table = btr_search_sys->hash_tables[i];

ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
/* this is only used for buf_pool->page_hash */
ut_ad(!table->heaps);
/* this is used for the adaptive hash index */
ut_ad(table->heap);

const mem_heap_t* heap = table->heap;
/* The heap may change during the following call,
so the data displayed may be garbage. We intentionally
avoid acquiring btr_search_latches[] so that the
diagnostic output will not stop here even in case another
thread hangs while holding btr_search_latches[].
This should be safe from crashes, because
table->heap will be pointing to the same object
for the full lifetime of the server. Even during
btr_search_disable() the heap will stay valid. */
fprintf(file, "Hash table size " ULINTPF
", node heap has " ULINTPF " buffer(s)\n",
table->n_cells, heap->base.count - !heap->free_block);
}

fprintf(file,
Expand Down

0 comments on commit a3476a5

Please sign in to comment.