Commit 3bd706ee authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-18582: Extend SHOW STATUS LIKE 'Innodb_%'

Many InnoDB internal variables and counters were only exposed
in an unstructured fashion via SHOW ENGINE INNODB STATUS.

Expose more variables via SHOW STATUS. Many of these were
exported in XtraDB.

Also, introduce SHOW_SIZE_T and use the proper size for
exporting the InnoDB variables.

Remove some unnecessary indirection via export_vars, and
bind some variables directly.

dict_sys_t::rough_size(): Replaces dict_sys_get_size()
and includes the hash table sizes.

This is based on a contribution by Tony Liu from ServiceNow.
parent c912fc30
......@@ -177,7 +177,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
SHOW_SIZE_T, SHOW_always_last
};
/* backward compatibility mapping. */
......
......@@ -432,7 +432,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
......
......@@ -432,7 +432,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
......
......@@ -432,7 +432,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
......
......@@ -432,7 +432,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
......
......@@ -432,7 +432,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
......
......@@ -3626,12 +3626,18 @@ const char* get_one_variable(THD *thd,
/* fall through */
case SHOW_ULONG:
case SHOW_LONG_NOFLUSH: // the difference lies in refresh_status()
#ifndef _WIN64
case SHOW_SIZE_T:
#endif
end= int10_to_str(*(long*) value, buff, 10);
break;
case SHOW_LONGLONG_STATUS:
value= ((char *) status_var + (intptr) value);
/* fall through */
case SHOW_ULONGLONG:
#ifdef _WIN64
case SHOW_SIZE_T:
#endif
end= longlong10_to_str(*(longlong*) value, buff, 10);
break;
case SHOW_HA_ROWS:
......
......@@ -63,7 +63,7 @@ static const ulint buf_flush_wait_flushed_sleep_time = 10000;
#include <my_service_manager.h>
/** Number of pages flushed through non flush_list flushes. */
static ulint buf_lru_flush_page_count = 0;
ulint buf_lru_flush_page_count;
/** Flag indicating if the page_cleaner is in active state. This flag
is set to TRUE by the page_cleaner thread when it is spawned and is set
......
......@@ -6504,25 +6504,6 @@ dict_tf_to_row_format_string(
return(0);
}
/** Calculate the used memory occupied by the data dictionary
table and index objects.
@return number of bytes occupied. */
UNIV_INTERN
ulint
dict_sys_get_size()
{
/* No mutex; this is a very crude approximation anyway */
ulint size = UT_LIST_GET_LEN(dict_sys.table_LRU)
+ UT_LIST_GET_LEN(dict_sys.table_non_LRU);
size *= sizeof(dict_table_t)
+ sizeof(dict_index_t) * 2
+ (sizeof(dict_col_t) + sizeof(dict_field_t)) * 10
+ sizeof(dict_field_t) * 5 /* total number of key fields */
+ 200; /* arbitrary, covering names and overhead */
return size;
}
/** Look for any dictionary objects that are found in the given tablespace.
@param[in] space_id Tablespace ID to search for.
@return true if tablespace is empty. */
......
This diff is collapsed.
......@@ -31,6 +31,9 @@ Created 11/5/1995 Heikki Tuuri
#include "log0log.h"
#include "buf0types.h"
/** Number of pages flushed through non flush_list flushes. */
extern ulint buf_lru_flush_page_count;
/** Flag indicating if the page_cleaner is in active state. */
extern bool buf_page_cleaner_is_active;
......
......@@ -1580,6 +1580,23 @@ class dict_sys_t
mutex_exit(&mutex);
rw_lock_x_unlock(&latch);
}
/** Estimate the used memory occupied by the data dictionary
table and index objects.
@return number of bytes occupied */
ulint rough_size() const
{
/* No mutex; this is a very crude approximation anyway */
ulint size = UT_LIST_GET_LEN(table_LRU) + UT_LIST_GET_LEN(table_non_LRU);
size *= sizeof(dict_table_t)
+ sizeof(dict_index_t) * 2
+ (sizeof(dict_col_t) + sizeof(dict_field_t)) * 10
+ sizeof(dict_field_t) * 5 /* total number of key fields */
+ 200; /* arbitrary, covering names and overhead */
size += (table_hash->n_cells + table_id_hash->n_cells
+ temp_id_hash->n_cells) * sizeof(hash_cell_t);
return size;
}
};
/** the data dictionary cache */
......@@ -1801,13 +1818,6 @@ dict_table_decode_n_col(
ulint* n_col,
ulint* n_v_col);
/** Calculate the used memory occupied by the data dictionary
table and index objects.
@return number of bytes occupied. */
UNIV_INTERN
ulint
dict_sys_get_size();
/** Look for any dictionary objects that are found in the given tablespace.
@param[in] space_id Tablespace ID to search for.
@return true if tablespace is empty. */
......
......@@ -90,6 +90,10 @@ struct srv_stats_t
doublewrite buffer */
ulint_ctr_1_t dblwr_pages_written;
#if defined(LINUX_NATIVE_AIO)
ulint_ctr_1_t buffered_aio_submitted;
#endif
/** Store the number of write requests issued */
ulint_ctr_1_t buf_pool_write_requests;
......@@ -184,6 +188,9 @@ struct srv_stats_t
/** Number of spaces in keyrotation list */
ulint_ctr_64_t key_rotation_list_length;
/** Number of lock deadlocks */
ulint_ctr_1_t lock_deadlock_count;
};
extern const char* srv_main_thread_op_info;
......@@ -511,6 +518,12 @@ extern uint srv_spin_wait_delay;
extern ulint srv_truncated_status_writes;
/** Number of initialized rollback segments for persistent undo log */
extern ulong srv_available_undo_logs;
/** Iterations of the loop bounded by 'srv_active' label. */
extern ulint srv_main_active_loops;
/** Iterations of the loop bounded by the 'srv_idle' label. */
extern ulint srv_main_idle_loops;
/** Log writes involving flush. */
extern ulint srv_log_writes_and_flush;
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
extern my_bool srv_ibuf_disable_background_merge;
......@@ -900,14 +913,6 @@ srv_master_thread_disabled_debug_update(THD*, st_mysql_sys_var*, void*,
/** Status variables to be passed to MySQL */
struct export_var_t{
ulint innodb_data_pending_reads; /*!< Pending reads */
ulint innodb_data_pending_writes; /*!< Pending writes */
ulint innodb_data_pending_fsyncs; /*!< Pending fsyncs */
ulint innodb_data_fsyncs; /*!< Number of fsyncs so far */
ulint innodb_data_read; /*!< Data bytes read */
ulint innodb_data_writes; /*!< I/O write requests */
ulint innodb_data_written; /*!< Data bytes written */
ulint innodb_data_reads; /*!< I/O read requests */
char innodb_buffer_pool_dump_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool dump status */
char innodb_buffer_pool_load_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool load status */
char innodb_buffer_pool_resize_status[512];/*!< Buf pool resize status */
......@@ -922,6 +927,9 @@ struct export_var_t{
#ifdef UNIV_DEBUG
ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
#endif /* UNIV_DEBUG */
ulint innodb_buffer_pool_pages_made_not_young;
ulint innodb_buffer_pool_pages_made_young;
ulint innodb_buffer_pool_pages_old;
ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */
ulint innodb_buffer_pool_reads; /*!< srv_buf_pool_reads */
ulint innodb_buffer_pool_wait_free; /*!< srv_buf_pool_wait_free */
......@@ -930,17 +938,35 @@ struct export_var_t{
ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */
ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */
ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
ulint innodb_checkpoint_age;
ulint innodb_checkpoint_max_age;
ulint innodb_data_pending_reads; /*!< Pending reads */
ulint innodb_data_pending_writes; /*!< Pending writes */
ulint innodb_data_pending_fsyncs; /*!< Pending fsyncs */
ulint innodb_data_fsyncs; /*!< Number of fsyncs so far */
ulint innodb_data_read; /*!< Data bytes read */
ulint innodb_data_writes; /*!< I/O write requests */
ulint innodb_data_written; /*!< Data bytes written */
ulint innodb_data_reads; /*!< I/O read requests */
ulint innodb_dblwr_pages_written; /*!< srv_dblwr_pages_written */
ulint innodb_dblwr_writes; /*!< srv_dblwr_writes */
ibool innodb_have_atomic_builtins; /*!< HAVE_ATOMIC_BUILTINS */
ulint innodb_deadlocks;
ulint innodb_history_list_length;
ulint innodb_log_waits; /*!< srv_log_waits */
ulint innodb_log_write_requests; /*!< srv_log_write_requests */
ulint innodb_log_writes; /*!< srv_log_writes */
lsn_t innodb_lsn_current;
lsn_t innodb_lsn_flushed;
lsn_t innodb_lsn_last_checkpoint;
trx_id_t innodb_max_trx_id;
#ifdef BTR_CUR_HASH_ADAPT
ulint innodb_mem_adaptive_hash;
#endif
ulint innodb_mem_dictionary;
lsn_t innodb_os_log_written; /*!< srv_os_log_written */
ulint innodb_os_log_fsyncs; /*!< fil_n_log_flushes */
ulint innodb_os_log_pending_writes; /*!< srv_os_log_pending_writes */
ulint innodb_os_log_pending_fsyncs; /*!< fil_n_pending_log_flushes */
ulint innodb_page_size; /*!< srv_page_size */
ulint innodb_pages_created; /*!< buf_pool->stat.n_pages_created */
ulint innodb_pages_read; /*!< buf_pool->stat.n_pages_read*/
ulint innodb_pages_written; /*!< buf_pool->stat.n_pages_written */
......@@ -963,6 +989,7 @@ struct export_var_t{
ulint innodb_system_rows_deleted; /*!< srv_n_system_rows_deleted*/
ulint innodb_num_open_files; /*!< fil_system_t::n_open */
ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */
/** Number of undo tablespace truncation operations */
ulong innodb_undo_truncations;
ulint innodb_defragment_compression_failures; /*!< Number of
......
......@@ -6973,6 +6973,7 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, trx_t* trx)
rollback_print(victim_trx, lock);
MONITOR_INC(MONITOR_DEADLOCK);
srv_stats.lock_deadlock_count.inc();
break;
......@@ -6985,6 +6986,7 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, trx_t* trx)
lock_deadlock_found = true;
MONITOR_INC(MONITOR_DEADLOCK);
srv_stats.lock_deadlock_count.inc();
}
} while (victim_trx != NULL && victim_trx != trx);
......
......@@ -1668,6 +1668,7 @@ LinuxAIOHandler::resubmit(Slot* slot)
/* Resubmit an I/O request */
int ret = io_submit(m_array->io_ctx(m_segment), 1, &iocb);
srv_stats.buffered_aio_submitted.inc();
if (ret < -1) {
errno = -ret;
......@@ -2032,6 +2033,7 @@ AIO::linux_dispatch(Slot* slot)
io_ctx_index = (slot->pos * m_n_segments) / m_slots.size();
int ret = io_submit(m_aio_ctx[io_ctx_index], 1, &iocb);
srv_stats.buffered_aio_submitted.inc();
/* io_submit() returns number of successfully queued requests
or -errno. */
......@@ -2214,6 +2216,7 @@ AIO::is_linux_native_aio_supported()
}
int err = io_submit(io_ctx, 1, &p_iocb);
srv_stats.buffered_aio_submitted.inc();
if (err >= 1) {
/* Now collect the submitted IO request. */
......
......@@ -448,13 +448,13 @@ static ulint srv_main_thread_id;
/* The following counts are used by the srv_master_thread. */
/** Iterations of the loop bounded by 'srv_active' label. */
static ulint srv_main_active_loops;
ulint srv_main_active_loops;
/** Iterations of the loop bounded by the 'srv_idle' label. */
static ulint srv_main_idle_loops;
ulint srv_main_idle_loops;
/** Iterations of the loop bounded by the 'srv_shutdown' label. */
static ulint srv_main_shutdown_loops;
/** Log writes involving flush. */
static ulint srv_log_writes_and_flush;
ulint srv_log_writes_and_flush;
/* This is only ever touched by the master thread. It records the
time when the last flush of log file has happened. The master
......@@ -1312,7 +1312,7 @@ srv_printf_innodb_monitor(
"Total large memory allocated " ULINTPF "\n"
"Dictionary memory allocated " ULINTPF "\n",
ulint{os_total_large_mem_allocated},
dict_sys_get_size());
dict_sys.rough_size());
buf_print_io(file);
......@@ -1421,6 +1421,27 @@ srv_export_innodb_status(void)
btr_scrub_total_stat(&scrub_stat);
}
#ifdef BTR_CUR_HASH_ADAPT
ulint mem_adaptive_hash = 0;
ut_ad(btr_search_sys->hash_tables);
for (ulong i = 0; i < btr_ahi_parts; 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_sync_obj);
ut_ad(!ht->heaps);
mem_adaptive_hash += mem_heap_get_size(ht->heap)
+ ht->n_cells * sizeof(hash_cell_t);
}
export_vars.innodb_mem_adaptive_hash = mem_adaptive_hash;
#endif
export_vars.innodb_mem_dictionary = dict_sys.rough_size();
mutex_enter(&srv_innodb_monitor_mutex);
export_vars.innodb_data_pending_reads =
......@@ -1473,6 +1494,18 @@ srv_export_innodb_status(void)
export_vars.innodb_buffer_pool_pages_dirty = flush_list_len;
export_vars.innodb_buffer_pool_pages_made_young
= stat.n_pages_made_young;
export_vars.innodb_buffer_pool_pages_made_not_young
= stat.n_pages_not_made_young;
export_vars.innodb_buffer_pool_pages_old = 0;
for (ulong i = 0; i < srv_buf_pool_instances; i++) {
export_vars.innodb_buffer_pool_pages_old +=
buf_pool_from_array(i)->LRU_old_len;
}
export_vars.innodb_buffer_pool_bytes_dirty =
buf_pools_list_size.flush_list_bytes;
......@@ -1487,13 +1520,8 @@ srv_export_innodb_status(void)
export_vars.innodb_buffer_pool_pages_misc =
buf_pool_get_n_pages() - LRU_len - free_len;
#ifdef HAVE_ATOMIC_BUILTINS
export_vars.innodb_have_atomic_builtins = 1;
#else
export_vars.innodb_have_atomic_builtins = 0;
#endif
export_vars.innodb_page_size = srv_page_size;
export_vars.innodb_max_trx_id = trx_sys.get_max_trx_id();
export_vars.innodb_history_list_length = trx_sys.rseg_history_len;
export_vars.innodb_log_waits = srv_stats.log_waits;
......@@ -1594,37 +1622,48 @@ srv_export_innodb_status(void)
srv_stats.n_sec_rec_cluster_reads_avoided;
if (!srv_read_only_mode) {
export_vars.innodb_encryption_rotation_pages_read_from_cache =
crypt_stat.pages_read_from_cache;
export_vars.innodb_encryption_rotation_pages_read_from_disk =
crypt_stat.pages_read_from_disk;
export_vars.innodb_encryption_rotation_pages_modified =
crypt_stat.pages_modified;
export_vars.innodb_encryption_rotation_pages_flushed =
crypt_stat.pages_flushed;
export_vars.innodb_encryption_rotation_estimated_iops =
crypt_stat.estimated_iops;
export_vars.innodb_encryption_key_requests =
srv_stats.n_key_requests;
export_vars.innodb_key_rotation_list_length =
srv_stats.key_rotation_list_length;
export_vars.innodb_scrub_page_reorganizations =
scrub_stat.page_reorganizations;
export_vars.innodb_scrub_page_splits =
scrub_stat.page_splits;
export_vars.innodb_scrub_page_split_failures_underflow =
scrub_stat.page_split_failures_underflow;
export_vars.innodb_scrub_page_split_failures_out_of_filespace =
scrub_stat.page_split_failures_out_of_filespace;
export_vars.innodb_scrub_page_split_failures_missing_index =
scrub_stat.page_split_failures_missing_index;
export_vars.innodb_scrub_page_split_failures_unknown =
scrub_stat.page_split_failures_unknown;
export_vars.innodb_scrub_log = srv_stats.n_log_scrubs;
export_vars.innodb_encryption_rotation_pages_read_from_cache =
crypt_stat.pages_read_from_cache;
export_vars.innodb_encryption_rotation_pages_read_from_disk =
crypt_stat.pages_read_from_disk;
export_vars.innodb_encryption_rotation_pages_modified =
crypt_stat.pages_modified;
export_vars.innodb_encryption_rotation_pages_flushed =
crypt_stat.pages_flushed;
export_vars.innodb_encryption_rotation_estimated_iops =
crypt_stat.estimated_iops;
export_vars.innodb_encryption_key_requests =
srv_stats.n_key_requests;
export_vars.innodb_key_rotation_list_length =
srv_stats.key_rotation_list_length;
export_vars.innodb_scrub_page_reorganizations =
scrub_stat.page_reorganizations;
export_vars.innodb_scrub_page_splits =
scrub_stat.page_splits;
export_vars.innodb_scrub_page_split_failures_underflow =
scrub_stat.page_split_failures_underflow;
export_vars.innodb_scrub_page_split_failures_out_of_filespace =
scrub_stat.page_split_failures_out_of_filespace;
export_vars.innodb_scrub_page_split_failures_missing_index =
scrub_stat.page_split_failures_missing_index;
export_vars.innodb_scrub_page_split_failures_unknown =
scrub_stat.page_split_failures_unknown;
export_vars.innodb_scrub_log = srv_stats.n_log_scrubs;
}
mutex_exit(&srv_innodb_monitor_mutex);
log_mutex_enter();
export_vars.innodb_lsn_current = log_sys.lsn;
export_vars.innodb_lsn_flushed = log_sys.flushed_to_disk_lsn;
export_vars.innodb_lsn_last_checkpoint = log_sys.last_checkpoint_lsn;
export_vars.innodb_checkpoint_age = log_sys.lsn
- log_sys.last_checkpoint_lsn;
export_vars.innodb_checkpoint_max_age = log_sys.max_checkpoint_age;
log_mutex_exit();
}
/*********************************************************************//**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment