MDEV-28542 Useless output in SHOW ENGINE INNODB STATUS

srv_printf_innodb_monitor(): Only display an ADAPTIVE HASH INDEX
section if the adaptive hash index is enabled.

ibuf_print(): Only display an INSERT BUFFER section if the
change buffer is not empty.
This commit is contained in:
Marko Mäkelä 2022-05-13 16:13:13 +03:00
parent 643fd51db5
commit 12aeb9fa15
4 changed files with 51 additions and 53 deletions

View file

@ -39,19 +39,13 @@ Table Op Msg_type Msg_text
test.t1 check Error Unknown storage engine 'InnoDB' test.t1 check Error Unknown storage engine 'InnoDB'
test.t1 check error Corrupt test.t1 check error Corrupt
FOUND 1 /innodb_read_only prevents crash recovery/ in mysqld.1.err FOUND 1 /innodb_read_only prevents crash recovery/ in mysqld.1.err
# restart: --innodb-force-recovery=5 # restart: --innodb-force-recovery=5 --debug-dbug=d,crash_after_log_ibuf_upd_inplace
SELECT * FROM t1 LIMIT 1; SELECT * FROM t1 LIMIT 1;
a b c a b c
1 X 1 1 X 1
SHOW ENGINE INNODB STATUS;
Type Name Status
InnoDB insert 0, delete mark 0
SET GLOBAL innodb_fast_shutdown=0; SET GLOBAL innodb_fast_shutdown=0;
# restart # restart
CHECK TABLE t1; CHECK TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
SHOW ENGINE INNODB STATUS;
Type Name Status
InnoDB
DROP TABLE t1; DROP TABLE t1;

View file

@ -67,16 +67,12 @@ CHECK TABLE t1;
let SEARCH_PATTERN=innodb_read_only prevents crash recovery; let SEARCH_PATTERN=innodb_read_only prevents crash recovery;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let $restart_parameters= --innodb-force-recovery=5 --let $restart_parameters= --innodb-force-recovery=5 --debug-dbug=d,crash_after_log_ibuf_upd_inplace
--source include/start_mysqld.inc --source include/start_mysqld.inc
SELECT * FROM t1 LIMIT 1; SELECT * FROM t1 LIMIT 1;
replace_regex /.*operations:.* (insert.*), delete \d.*discarded .*/\1/;
SHOW ENGINE INNODB STATUS;
# Slow shutdown will not merge the changes due to innodb_force_recovery=5. # Slow shutdown will not merge the changes due to innodb_force_recovery=5.
SET GLOBAL innodb_fast_shutdown=0; SET GLOBAL innodb_fast_shutdown=0;
--let $restart_parameters= --let $restart_parameters=
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
CHECK TABLE t1; CHECK TABLE t1;
replace_regex /.*operations:.* insert [1-9][0-9]*, delete mark [1-9][0-9]*, delete \d.*discarded .*//;
SHOW ENGINE INNODB STATUS;
DROP TABLE t1; DROP TABLE t1;

View file

@ -1218,6 +1218,7 @@ static
void void
ibuf_print_ops( ibuf_print_ops(
/*===========*/ /*===========*/
const char* op_name,/*!< in: operation name */
const Atomic_counter<ulint>* ops, /*!< in: operation counts */ const Atomic_counter<ulint>* ops, /*!< in: operation counts */
FILE* file) /*!< in: file where to print */ FILE* file) /*!< in: file where to print */
{ {
@ -1226,11 +1227,11 @@ ibuf_print_ops(
"delete mark", "delete mark",
"delete" "delete"
}; };
ulint i;
ut_a(UT_ARR_SIZE(op_names) == IBUF_OP_COUNT); static_assert(array_elements(op_names) == IBUF_OP_COUNT, "");
fputs(op_name, file);
for (i = 0; i < IBUF_OP_COUNT; i++) { for (ulint i = 0; i < IBUF_OP_COUNT; i++) {
fprintf(file, "%s " ULINTPF "%s", op_names[i], fprintf(file, "%s " ULINTPF "%s", op_names[i],
ulint{ops[i]}, (i < (IBUF_OP_COUNT - 1)) ? ", " : ""); ulint{ops[i]}, (i < (IBUF_OP_COUNT - 1)) ? ", " : "");
} }
@ -4547,23 +4548,28 @@ ibuf_print(
/*=======*/ /*=======*/
FILE* file) /*!< in: file where to print */ FILE* file) /*!< in: file where to print */
{ {
mysql_mutex_lock(&ibuf_mutex);
fprintf(file, mysql_mutex_lock(&ibuf_mutex);
"Ibuf: size " ULINTPF ", free list len " ULINTPF "," if (ibuf.empty)
" seg size " ULINTPF ", " ULINTPF " merges\n", {
ibuf.size, mysql_mutex_unlock(&ibuf_mutex);
ibuf.free_list_len, return;
ibuf.seg_size, }
ulint{ibuf.n_merges});
fputs("merged operations:\n ", file); const ulint size= ibuf.size;
ibuf_print_ops(ibuf.n_merged_ops, file); const ulint free_list_len= ibuf.free_list_len;
const ulint seg_size= ibuf.seg_size;
mysql_mutex_unlock(&ibuf_mutex);
fputs("discarded operations:\n ", file); fprintf(file,
ibuf_print_ops(ibuf.n_discarded_ops, file); "-------------\n"
"INSERT BUFFER\n"
mysql_mutex_unlock(&ibuf_mutex); "-------------\n"
"size " ULINTPF ", free list len " ULINTPF ","
" seg size " ULINTPF ", " ULINTPF " merges\n",
size, free_list_len, seg_size, ulint{ibuf.n_merges});
ibuf_print_ops("merged operations:\n", ibuf.n_merged_ops, file);
ibuf_print_ops("discarded operations:\n", ibuf.n_discarded_ops, file);
} }
/** Check the insert buffer bitmaps on IMPORT TABLESPACE. /** Check the insert buffer bitmaps on IMPORT TABLESPACE.

View file

@ -828,34 +828,36 @@ srv_printf_innodb_monitor(
"--------\n", file); "--------\n", file);
os_aio_print(file); os_aio_print(file);
fputs("-------------------------------------\n"
"INSERT BUFFER AND ADAPTIVE HASH INDEX\n"
"-------------------------------------\n", file);
ibuf_print(file); ibuf_print(file);
#ifdef BTR_CUR_HASH_ADAPT #ifdef BTR_CUR_HASH_ADAPT
for (ulint i = 0; i < btr_ahi_parts && btr_search_enabled; ++i) { if (btr_search_enabled) {
const auto part= &btr_search_sys.parts[i]; fputs("-------------------\n"
part->latch.rd_lock(SRW_LOCK_CALL); "ADAPTIVE HASH INDEX\n"
ut_ad(part->heap->type == MEM_HEAP_FOR_BTR_SEARCH); "-------------------\n", file);
fprintf(file, "Hash table size " ULINTPF for (ulint i = 0; i < btr_ahi_parts; ++i) {
", node heap has " ULINTPF " buffer(s)\n", const auto part= &btr_search_sys.parts[i];
part->table.n_cells, part->latch.rd_lock(SRW_LOCK_CALL);
part->heap->base.count - !part->heap->free_block); ut_ad(part->heap->type == MEM_HEAP_FOR_BTR_SEARCH);
part->latch.rd_unlock(); fprintf(file, "Hash table size " ULINTPF
} ", node heap has " ULINTPF " buffer(s)\n",
part->table.n_cells,
part->heap->base.count
- !part->heap->free_block);
part->latch.rd_unlock();
}
/* btr_cur_n_sea_old and btr_cur_n_non_sea_old are protected by const ulint with_ahi = btr_cur_n_sea;
srv_innodb_monitor_mutex (srv_refresh_innodb_monitor_stats) */ const ulint without_ahi = btr_cur_n_non_sea;
const ulint with_ahi = btr_cur_n_sea, without_ahi = btr_cur_n_non_sea; fprintf(file,
fprintf(file, "%.2f hash searches/s, %.2f non-hash searches/s\n",
"%.2f hash searches/s, %.2f non-hash searches/s\n", static_cast<double>(with_ahi - btr_cur_n_sea_old)
static_cast<double>(with_ahi - btr_cur_n_sea_old) / time_elapsed,
/ time_elapsed, static_cast<double>(without_ahi - btr_cur_n_non_sea_old)
static_cast<double>(without_ahi - btr_cur_n_non_sea_old) / time_elapsed);
/ time_elapsed); btr_cur_n_sea_old = with_ahi;
btr_cur_n_sea_old = with_ahi; btr_cur_n_non_sea_old = without_ahi;
btr_cur_n_non_sea_old = without_ahi; }
#endif /* BTR_CUR_HASH_ADAPT */ #endif /* BTR_CUR_HASH_ADAPT */
fputs("---\n" fputs("---\n"