1 # name : innodb_show_status.patch
2 # introduced : 11 or before
3 # maintainer : Yasufumi
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 diff -ruN a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c
9 --- a/storage/innobase/buf/buf0buf.c 2010-11-03 07:01:13.000000000 +0900
10 +++ b/storage/innobase/buf/buf0buf.c 2010-12-03 15:07:31.786968193 +0900
14 total_info->pool_size += pool_info->pool_size;
15 + total_info->pool_size_bytes += pool_info->pool_size_bytes;
16 total_info->lru_len += pool_info->lru_len;
17 total_info->old_lru_len += pool_info->old_lru_len;
18 total_info->free_list_len += pool_info->free_list_len;
21 pool_info->pool_size = buf_pool->curr_size;
23 + pool_info->pool_size_bytes = buf_pool->curr_pool_size;
25 pool_info->lru_len = UT_LIST_GET_LEN(buf_pool->LRU);
27 pool_info->old_lru_len = buf_pool->LRU_old_len;
28 @@ -5010,14 +5013,16 @@
32 - "Buffer pool size %lu\n"
33 - "Free buffers %lu\n"
34 - "Database pages %lu\n"
35 - "Old database pages %lu\n"
36 - "Modified db pages %lu\n"
37 + "Buffer pool size %lu\n"
38 + "Buffer pool size, bytes %lu\n"
39 + "Free buffers %lu\n"
40 + "Database pages %lu\n"
41 + "Old database pages %lu\n"
42 + "Modified db pages %lu\n"
44 "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
46 + pool_info->pool_size_bytes,
47 pool_info->free_list_len,
49 pool_info->old_lru_len,
50 diff -ruN a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c
51 --- a/storage/innobase/buf/buf0flu.c 2010-12-03 20:58:26.000000000 +0300
52 +++ b/storage/innobase/buf/buf0flu.c 2011-01-07 03:37:41.000000000 +0300
54 static buf_flush_stat_t buf_flush_stat_sum;
56 /** Number of pages flushed through non flush_list flushes. */
57 -static ulint buf_lru_flush_page_count = 0;
58 +// static ulint buf_lru_flush_page_count = 0;
62 diff -ruN a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c
63 --- a/storage/innobase/fil/fil0fil.c 2010-11-03 07:01:13.000000000 +0900
64 +++ b/storage/innobase/fil/fil0fil.c 2010-12-03 15:07:31.790357112 +0900
65 @@ -4888,3 +4888,30 @@
70 +/*************************************************************************
71 +Return local hash table informations. */
74 +fil_system_hash_cells(void)
75 +/*=======================*/
78 + return (fil_system->spaces->n_cells
79 + + fil_system->name_hash->n_cells);
86 +fil_system_hash_nodes(void)
87 +/*=======================*/
90 + return (UT_LIST_GET_LEN(fil_system->space_list)
91 + * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
96 diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
97 --- a/storage/innobase/handler/ha_innodb.cc 2010-12-03 15:06:58.727955654 +0900
98 +++ b/storage/innobase/handler/ha_innodb.cc 2010-12-03 15:07:31.799376984 +0900
100 (char*) &export_vars.innodb_buffer_pool_pages_dirty, SHOW_LONG},
101 {"buffer_pool_pages_flushed",
102 (char*) &export_vars.innodb_buffer_pool_pages_flushed, SHOW_LONG},
103 + {"buffer_pool_pages_LRU_flushed",
104 + (char*) &export_vars.innodb_buffer_pool_pages_LRU_flushed, SHOW_LONG},
105 {"buffer_pool_pages_free",
106 (char*) &export_vars.innodb_buffer_pool_pages_free, SHOW_LONG},
108 @@ -11081,6 +11083,16 @@
109 "Force InnoDB to not use next-key locking, to use only row-level locking.",
112 +static MYSQL_SYSVAR_ULONG(show_verbose_locks, srv_show_verbose_locks,
113 + PLUGIN_VAR_OPCMDARG,
114 + "Whether to show records locked in SHOW INNODB STATUS.",
115 + NULL, NULL, 0, 0, 1, 0);
117 +static MYSQL_SYSVAR_ULONG(show_locks_held, srv_show_locks_held,
118 + PLUGIN_VAR_RQCMDARG,
119 + "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
120 + NULL, NULL, 10, 0, 1000, 0);
122 #ifdef UNIV_LOG_ARCHIVE
123 static MYSQL_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
124 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
125 @@ -11268,7 +11280,7 @@
127 static MYSQL_SYSVAR_STR(version, innodb_version_str,
128 PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
129 - "InnoDB version", NULL, NULL, INNODB_VERSION_STR);
130 + "Percona-InnoDB-plugin version", NULL, NULL, INNODB_VERSION_STR);
132 static MYSQL_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
133 PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
134 @@ -11361,6 +11373,8 @@
135 MYSQL_SYSVAR(thread_concurrency),
136 MYSQL_SYSVAR(thread_sleep_delay),
137 MYSQL_SYSVAR(autoinc_lock_mode),
138 + MYSQL_SYSVAR(show_verbose_locks),
139 + MYSQL_SYSVAR(show_locks_held),
140 MYSQL_SYSVAR(version),
141 MYSQL_SYSVAR(use_sys_malloc),
142 MYSQL_SYSVAR(use_native_aio),
143 diff -ruN a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
144 --- a/storage/innobase/include/buf0buf.h 2011-01-20 07:37:08.000000000 +0900
145 +++ b/storage/innobase/include/buf0buf.h 2011-02-14 15:25:20.859126532 +0900
147 /* General buffer pool info */
148 ulint pool_unique_id; /*!< Buffer Pool ID */
149 ulint pool_size; /*!< Buffer Pool size in pages */
150 + ulint pool_size_bytes;
151 ulint lru_len; /*!< Length of buf_pool->LRU */
152 ulint old_lru_len; /*!< buf_pool->LRU_old_len */
153 ulint free_list_len; /*!< Length of buf_pool->free list */
154 diff -ruN a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
155 --- a/storage/innobase/include/fil0fil.h 2010-11-03 07:01:13.000000000 +0900
156 +++ b/storage/innobase/include/fil0fil.h 2010-12-03 15:07:31.812028575 +0900
158 /*============================*/
159 ulint id); /*!< in: space id */
161 +/*************************************************************************
162 +Return local hash table informations. */
165 +fil_system_hash_cells(void);
166 +/*========================*/
169 +fil_system_hash_nodes(void);
170 +/*========================*/
172 typedef struct fil_space_struct fil_space_t;
175 diff -ruN a/storage/innobase/include/read0read.h b/storage/innobase/include/read0read.h
176 --- a/storage/innobase/include/read0read.h 2010-12-04 02:58:26.000000000 +0900
177 +++ b/storage/innobase/include/read0read.h 2011-01-21 19:35:44.127631727 +0900
183 const read_view_t* view); /*!< in: read view */
184 /*********************************************************************//**
185 Create a consistent cursor view for mysql to be used in cursors. In this
186 diff -ruN a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
187 --- a/storage/innobase/include/srv0srv.h 2010-11-03 07:01:13.000000000 +0900
188 +++ b/storage/innobase/include/srv0srv.h 2010-12-03 15:07:31.813958103 +0900
190 extern char srv_adaptive_flushing;
193 +extern ulint srv_show_locks_held;
194 +extern ulint srv_show_verbose_locks;
196 /* The sort order table of the MySQL latin1_swedish_ci character set
198 extern const byte* srv_latin1_ordering;
200 buffer pool to disk */
201 extern ulint srv_buf_pool_flushed;
203 +extern ulint buf_lru_flush_page_count;
205 /** Number of buffer pool reads that led to the
206 reading of a disk page */
207 extern ulint srv_buf_pool_reads;
209 ulint innodb_buffer_pool_reads; /*!< srv_buf_pool_reads */
210 ulint innodb_buffer_pool_wait_free; /*!< srv_buf_pool_wait_free */
211 ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
212 + ulint innodb_buffer_pool_pages_LRU_flushed; /*!< buf_lru_flush_page_count */
213 ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
214 ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */
215 ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
216 diff -ruN a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c
217 --- a/storage/innobase/lock/lock0lock.c 2010-11-03 07:01:13.000000000 +0900
218 +++ b/storage/innobase/lock/lock0lock.c 2010-12-03 15:07:31.819023998 +0900
219 @@ -4374,6 +4374,7 @@
223 + if ( srv_show_verbose_locks ) {
224 block = buf_page_try_get(space, page_no, &mtr);
226 for (i = 0; i < lock_rec_get_n_bits(lock); ++i) {
227 @@ -4400,6 +4401,7 @@
234 if (UNIV_LIKELY_NULL(heap)) {
235 @@ -4583,7 +4585,7 @@
239 - if (!srv_print_innodb_lock_monitor) {
240 + if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
244 @@ -4655,8 +4657,8 @@
248 - if (nth_lock >= 10) {
249 - fputs("10 LOCKS PRINTED FOR THIS TRX:"
250 + if (nth_lock >= srv_show_locks_held) {
251 + fputs("TOO MANY LOCKS PRINTED FOR THIS TRX:"
252 " SUPPRESSING FURTHER PRINTS\n",
255 diff -ruN a/storage/innobase/read/read0read.c b/storage/innobase/read/read0read.c
256 --- a/storage/innobase/read/read0read.c 2010-12-04 02:58:26.000000000 +0900
257 +++ b/storage/innobase/read/read0read.c 2011-01-21 19:37:08.292650181 +0900
258 @@ -357,34 +357,35 @@
263 const read_view_t* view) /*!< in: read view */
268 if (view->type == VIEW_HIGH_GRANULARITY) {
271 "High-granularity read view undo_n:o %llu\n",
272 (ullint) view->undo_no);
274 - fprintf(stderr, "Normal read view\n");
275 + fprintf(file, "Normal read view\n");
278 - fprintf(stderr, "Read view low limit trx n:o " TRX_ID_FMT "\n",
279 + fprintf(file, "Read view low limit trx n:o " TRX_ID_FMT "\n",
280 (ullint) view->low_limit_no);
282 - fprintf(stderr, "Read view up limit trx id " TRX_ID_FMT "\n",
283 + fprintf(file, "Read view up limit trx id " TRX_ID_FMT "\n",
284 (ullint) view->up_limit_id);
286 - fprintf(stderr, "Read view low limit trx id " TRX_ID_FMT "\n",
287 + fprintf(file, "Read view low limit trx id " TRX_ID_FMT "\n",
288 (ullint) view->low_limit_id);
290 - fprintf(stderr, "Read view individually stored trx ids:\n");
291 + fprintf(file, "Read view individually stored trx ids:\n");
293 n_ids = view->n_trx_ids;
295 for (i = 0; i < n_ids; i++) {
296 - fprintf(stderr, "Read view trx id " TRX_ID_FMT "\n",
297 + fprintf(file, "Read view trx id " TRX_ID_FMT "\n",
298 (ullint) read_view_get_nth_trx_id(view, i));
301 diff -ruN a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
302 --- a/storage/innobase/srv/srv0srv.c 2010-11-03 07:01:13.000000000 +0900
303 +++ b/storage/innobase/srv/srv0srv.c 2010-12-03 15:07:31.824022673 +0900
305 #include "ha_prototypes.h"
307 #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */
308 +#include "read0read.h"
309 #include "mysql/plugin.h"
310 #include "mysql/service_thd_wait.h"
314 UNIV_INTERN char srv_adaptive_flushing = TRUE;
316 +UNIV_INTERN ulint srv_show_locks_held = 10;
317 +UNIV_INTERN ulint srv_show_verbose_locks = 0;
319 /** Maximum number of times allowed to conditionally acquire
320 mutex before switching to blocking wait on the mutex */
321 #define MAX_MUTEX_NOWAIT 20
323 /* variable to count the number of pages that were written from buffer
325 UNIV_INTERN ulint srv_buf_pool_flushed = 0;
326 +UNIV_INTERN ulint buf_lru_flush_page_count = 0;
328 /** Number of buffer pool reads that led to the
329 reading of a disk page */
330 @@ -1823,6 +1828,13 @@
334 + ulint btr_search_sys_subtotal;
335 + ulint lock_sys_subtotal;
336 + ulint recv_sys_subtotal;
341 mutex_enter(&srv_innodb_monitor_mutex);
343 current_time = time(NULL);
344 @@ -1871,31 +1883,6 @@
346 mutex_exit(&dict_foreign_err_mutex);
348 - /* Only if lock_print_info_summary proceeds correctly,
349 - before we call the lock_print_info_all_transactions
350 - to print all the lock information. */
351 - ret = lock_print_info_summary(file, nowait);
355 - long t = ftell(file);
357 - *trx_start = ULINT_UNDEFINED;
359 - *trx_start = (ulint) t;
362 - lock_print_info_all_transactions(file);
364 - long t = ftell(file);
366 - *trx_end = ULINT_UNDEFINED;
368 - *trx_end = (ulint) t;
376 @@ -1926,10 +1913,78 @@
377 "BUFFER POOL AND MEMORY\n"
378 "----------------------\n", file);
380 - "Total memory allocated " ULINTPF
381 - "; in additional pool allocated " ULINTPF "\n",
382 - ut_total_allocated_memory,
383 - mem_pool_get_reserved(mem_comm_pool));
384 + "Total memory allocated " ULINTPF
385 + "; in additional pool allocated " ULINTPF "\n",
386 + ut_total_allocated_memory,
387 + mem_pool_get_reserved(mem_comm_pool));
388 + /* Calcurate reserved memories */
389 + if (btr_search_sys && btr_search_sys->hash_index->heap) {
390 + btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
392 + btr_search_sys_subtotal = 0;
393 + for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
394 + btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
398 + lock_sys_subtotal = 0;
400 + mutex_enter(&kernel_mutex);
401 + trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
403 + lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
404 + trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
406 + mutex_exit(&kernel_mutex);
409 + recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
410 + ? mem_heap_get_size(recv_sys->heap) : 0);
413 + "Internal hash tables (constant factor + variable factor)\n"
414 + " Adaptive hash index %lu \t(%lu + %lu)\n"
415 + " Page hash %lu (buffer pool 0 only)\n"
416 + " Dictionary cache %lu \t(%lu + %lu)\n"
417 + " File system %lu \t(%lu + %lu)\n"
418 + " Lock system %lu \t(%lu + %lu)\n"
419 + " Recovery system %lu \t(%lu + %lu)\n",
421 + (ulong) (btr_search_sys
422 + ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
423 + + btr_search_sys_subtotal,
424 + (ulong) (btr_search_sys
425 + ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
426 + (ulong) btr_search_sys_subtotal,
428 + (ulong) (buf_pool_from_array(0)->page_hash->n_cells * sizeof(hash_cell_t)),
430 + (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
431 + + dict_sys->table_id_hash->n_cells
432 + ) * sizeof(hash_cell_t)
433 + + dict_sys->size) : 0),
434 + (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
435 + + dict_sys->table_id_hash->n_cells
436 + ) * sizeof(hash_cell_t)) : 0),
437 + (ulong) (dict_sys ? (dict_sys->size) : 0),
439 + (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
440 + + fil_system_hash_nodes()),
441 + (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
442 + (ulong) fil_system_hash_nodes(),
444 + (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
445 + + lock_sys_subtotal),
446 + (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
447 + (ulong) lock_sys_subtotal,
449 + (ulong) (((recv_sys && recv_sys->addr_hash)
450 + ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
451 + + recv_sys_subtotal),
452 + (ulong) ((recv_sys && recv_sys->addr_hash)
453 + ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
454 + (ulong) recv_sys_subtotal);
456 fprintf(file, "Dictionary memory allocated " ULINTPF "\n",
459 @@ -1945,6 +2000,16 @@
460 fprintf(file, "%lu read views open inside InnoDB\n",
461 UT_LIST_GET_LEN(trx_sys->view_list));
463 + if (UT_LIST_GET_LEN(trx_sys->view_list)) {
464 + read_view_t* view = UT_LIST_GET_LAST(trx_sys->view_list);
467 + fprintf(file, "---OLDEST VIEW---\n");
468 + read_view_print(file, view);
469 + fprintf(file, "-----------------\n");
473 n_reserved = fil_space_get_n_reserved_extents(0);
474 if (n_reserved > 0) {
476 @@ -1988,6 +2053,31 @@
477 srv_n_rows_deleted_old = srv_n_rows_deleted;
478 srv_n_rows_read_old = srv_n_rows_read;
480 + /* Only if lock_print_info_summary proceeds correctly,
481 + before we call the lock_print_info_all_transactions
482 + to print all the lock information. */
483 + ret = lock_print_info_summary(file, nowait);
487 + long t = ftell(file);
489 + *trx_start = ULINT_UNDEFINED;
491 + *trx_start = (ulint) t;
494 + lock_print_info_all_transactions(file);
496 + long t = ftell(file);
498 + *trx_end = ULINT_UNDEFINED;
500 + *trx_end = (ulint) t;
505 fputs("----------------------------\n"
506 "END OF INNODB MONITOR OUTPUT\n"
507 "============================\n", file);
508 @@ -2031,6 +2121,7 @@
509 = srv_buf_pool_write_requests;
510 export_vars.innodb_buffer_pool_wait_free = srv_buf_pool_wait_free;
511 export_vars.innodb_buffer_pool_pages_flushed = srv_buf_pool_flushed;
512 + export_vars.innodb_buffer_pool_pages_LRU_flushed = buf_lru_flush_page_count;
513 export_vars.innodb_buffer_pool_reads = srv_buf_pool_reads;
514 export_vars.innodb_buffer_pool_read_ahead
515 = stat.n_ra_pages_read;
516 diff -ruN a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c
517 --- a/storage/innobase/sync/sync0arr.c 2010-11-03 07:01:13.000000000 +0900
518 +++ b/storage/innobase/sync/sync0arr.c 2010-12-03 15:07:31.826041368 +0900
522 "--Thread %lu has waited at %s line %lu"
523 - " for %.2f seconds the semaphore:\n",
524 + " for %#.5g seconds the semaphore:\n",
525 (ulong) os_thread_pf(cell->thread),
526 innobase_basename(cell->file), (ulong) cell->line,
527 difftime(time(NULL), cell->reservation_time));
528 diff -ruN a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c
529 --- a/storage/innobase/trx/trx0purge.c 2010-12-04 02:58:26.000000000 +0900
530 +++ b/storage/innobase/trx/trx0purge.c 2011-01-21 19:40:42.086683671 +0900
531 @@ -1212,7 +1212,7 @@
532 /*=====================*/
534 fprintf(stderr, "InnoDB: Purge system view:\n");
535 - read_view_print(purge_sys->view);
536 + read_view_print(stderr, purge_sys->view);
538 fprintf(stderr, "InnoDB: Purge trx n:o " TRX_ID_FMT
539 ", undo n:o " TRX_ID_FMT "\n",