]> git.pld-linux.org Git - packages/mysql.git/blame - innodb_show_status.patch
- rel. 2
[packages/mysql.git] / innodb_show_status.patch
CommitLineData
b4e1fa2c
AM
1# name : innodb_show_status.patch
2# introduced : 11 or before
3# maintainer : Yasufumi
4#
5#!!! notice !!!
6# Any small change to this file in the main branch
7# should be done or reviewed by the maintainer!
db82db79
AM
8--- a/storage/innobase/buf/buf0buf.c
9+++ b/storage/innobase/buf/buf0buf.c
29ffd636 10@@ -4372,6 +4372,7 @@
d8778560
AM
11 }
12
13 total_info->pool_size += pool_info->pool_size;
14+ total_info->pool_size_bytes += pool_info->pool_size_bytes;
15 total_info->lru_len += pool_info->lru_len;
16 total_info->old_lru_len += pool_info->old_lru_len;
17 total_info->free_list_len += pool_info->free_list_len;
29ffd636 18@@ -4437,6 +4438,8 @@
d8778560
AM
19
20 pool_info->pool_size = buf_pool->curr_size;
21
22+ pool_info->pool_size_bytes = buf_pool->curr_pool_size;
23+
24 pool_info->lru_len = UT_LIST_GET_LEN(buf_pool->LRU);
25
26 pool_info->old_lru_len = buf_pool->LRU_old_len;
29ffd636 27@@ -4558,14 +4561,16 @@
d8778560 28 ut_ad(pool_info);
b4e1fa2c
AM
29
30 fprintf(file,
31- "Buffer pool size %lu\n"
32- "Free buffers %lu\n"
33- "Database pages %lu\n"
34- "Old database pages %lu\n"
35- "Modified db pages %lu\n"
36+ "Buffer pool size %lu\n"
37+ "Buffer pool size, bytes %lu\n"
38+ "Free buffers %lu\n"
39+ "Database pages %lu\n"
40+ "Old database pages %lu\n"
41+ "Modified db pages %lu\n"
42 "Pending reads %lu\n"
43 "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
d8778560
AM
44 pool_info->pool_size,
45+ pool_info->pool_size_bytes,
46 pool_info->free_list_len,
47 pool_info->lru_len,
48 pool_info->old_lru_len,
db82db79
AM
49--- a/storage/innobase/buf/buf0flu.c
50+++ b/storage/innobase/buf/buf0flu.c
b4e1fa2c
AM
51@@ -75,7 +75,7 @@
52 static buf_flush_stat_t buf_flush_stat_sum;
53
54 /** Number of pages flushed through non flush_list flushes. */
55-static ulint buf_lru_flush_page_count = 0;
56+// static ulint buf_lru_flush_page_count = 0;
57
58 /* @} */
59
db82db79
AM
60--- a/storage/innobase/fil/fil0fil.c
61+++ b/storage/innobase/fil/fil0fil.c
29ffd636 62@@ -4897,3 +4897,30 @@
b4e1fa2c
AM
63
64 fil_system = NULL;
65 }
66+
67+/*************************************************************************
68+Return local hash table informations. */
69+
70+ulint
71+fil_system_hash_cells(void)
72+/*=======================*/
73+{
74+ if (fil_system) {
75+ return (fil_system->spaces->n_cells
76+ + fil_system->name_hash->n_cells);
77+ } else {
78+ return 0;
79+ }
80+}
81+
82+ulint
83+fil_system_hash_nodes(void)
84+/*=======================*/
85+{
86+ if (fil_system) {
87+ return (UT_LIST_GET_LEN(fil_system->space_list)
88+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
89+ } else {
90+ return 0;
91+ }
92+}
db82db79
AM
93--- a/storage/innobase/handler/ha_innodb.cc
94+++ b/storage/innobase/handler/ha_innodb.cc
95@@ -604,6 +604,8 @@
b4e1fa2c
AM
96 (char*) &export_vars.innodb_buffer_pool_pages_dirty, SHOW_LONG},
97 {"buffer_pool_pages_flushed",
98 (char*) &export_vars.innodb_buffer_pool_pages_flushed, SHOW_LONG},
99+ {"buffer_pool_pages_LRU_flushed",
100+ (char*) &export_vars.innodb_buffer_pool_pages_LRU_flushed, SHOW_LONG},
101 {"buffer_pool_pages_free",
102 (char*) &export_vars.innodb_buffer_pool_pages_free, SHOW_LONG},
103 #ifdef UNIV_DEBUG
29ffd636 104@@ -11207,6 +11209,16 @@
b4e1fa2c
AM
105 "Force InnoDB to not use next-key locking, to use only row-level locking.",
106 NULL, NULL, FALSE);
107
108+static MYSQL_SYSVAR_ULONG(show_verbose_locks, srv_show_verbose_locks,
109+ PLUGIN_VAR_OPCMDARG,
110+ "Whether to show records locked in SHOW INNODB STATUS.",
111+ NULL, NULL, 0, 0, 1, 0);
112+
113+static MYSQL_SYSVAR_ULONG(show_locks_held, srv_show_locks_held,
114+ PLUGIN_VAR_RQCMDARG,
115+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
116+ NULL, NULL, 10, 0, 1000, 0);
117+
118 #ifdef UNIV_LOG_ARCHIVE
119 static MYSQL_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
120 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
29ffd636 121@@ -11394,7 +11406,7 @@
b4e1fa2c
AM
122
123 static MYSQL_SYSVAR_STR(version, innodb_version_str,
124 PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
125- "InnoDB version", NULL, NULL, INNODB_VERSION_STR);
126+ "Percona-InnoDB-plugin version", NULL, NULL, INNODB_VERSION_STR);
127
128 static MYSQL_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
129 PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
29ffd636 130@@ -11494,6 +11506,8 @@
b4e1fa2c
AM
131 MYSQL_SYSVAR(thread_concurrency),
132 MYSQL_SYSVAR(thread_sleep_delay),
133 MYSQL_SYSVAR(autoinc_lock_mode),
134+ MYSQL_SYSVAR(show_verbose_locks),
135+ MYSQL_SYSVAR(show_locks_held),
136 MYSQL_SYSVAR(version),
137 MYSQL_SYSVAR(use_sys_malloc),
138 MYSQL_SYSVAR(use_native_aio),
db82db79
AM
139--- a/storage/innobase/include/buf0buf.h
140+++ b/storage/innobase/include/buf0buf.h
141@@ -128,6 +128,7 @@
d8778560
AM
142 /* General buffer pool info */
143 ulint pool_unique_id; /*!< Buffer Pool ID */
144 ulint pool_size; /*!< Buffer Pool size in pages */
145+ ulint pool_size_bytes;
146 ulint lru_len; /*!< Length of buf_pool->LRU */
147 ulint old_lru_len; /*!< buf_pool->LRU_old_len */
148 ulint free_list_len; /*!< Length of buf_pool->free list */
db82db79
AM
149--- a/storage/innobase/include/fil0fil.h
150+++ b/storage/innobase/include/fil0fil.h
29ffd636 151@@ -731,6 +731,17 @@
b4e1fa2c
AM
152 /*============================*/
153 ulint id); /*!< in: space id */
154
155+/*************************************************************************
156+Return local hash table informations. */
157+
158+ulint
159+fil_system_hash_cells(void);
160+/*========================*/
161+
162+ulint
163+fil_system_hash_nodes(void);
164+/*========================*/
165+
166 typedef struct fil_space_struct fil_space_t;
167
168 #endif
db82db79
AM
169--- a/storage/innobase/include/read0read.h
170+++ b/storage/innobase/include/read0read.h
b4e1fa2c
AM
171@@ -88,6 +88,7 @@
172 void
173 read_view_print(
174 /*============*/
175+ FILE* file,
176 const read_view_t* view); /*!< in: read view */
177 /*********************************************************************//**
178 Create a consistent cursor view for mysql to be used in cursors. In this
db82db79
AM
179--- a/storage/innobase/include/srv0srv.h
180+++ b/storage/innobase/include/srv0srv.h
734d6226
AM
181@@ -146,6 +146,9 @@
182 corrupted index and table */
183 extern my_bool srv_load_corrupted;
b4e1fa2c
AM
184
185+extern ulint srv_show_locks_held;
186+extern ulint srv_show_verbose_locks;
187+
188 /* The sort order table of the MySQL latin1_swedish_ci character set
189 collation */
190 extern const byte* srv_latin1_ordering;
734d6226 191@@ -328,6 +331,8 @@
b4e1fa2c
AM
192 buffer pool to disk */
193 extern ulint srv_buf_pool_flushed;
194
195+extern ulint buf_lru_flush_page_count;
196+
197 /** Number of buffer pool reads that led to the
198 reading of a disk page */
199 extern ulint srv_buf_pool_reads;
734d6226 200@@ -707,6 +712,7 @@
b4e1fa2c
AM
201 ulint innodb_buffer_pool_reads; /*!< srv_buf_pool_reads */
202 ulint innodb_buffer_pool_wait_free; /*!< srv_buf_pool_wait_free */
203 ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
204+ ulint innodb_buffer_pool_pages_LRU_flushed; /*!< buf_lru_flush_page_count */
205 ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
734d6226 206 ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */
b4e1fa2c 207 ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */
db82db79
AM
208--- a/storage/innobase/lock/lock0lock.c
209+++ b/storage/innobase/lock/lock0lock.c
210@@ -4377,6 +4377,7 @@
b4e1fa2c
AM
211
212 putc('\n', file);
213
214+ if ( srv_show_verbose_locks ) {
215 block = buf_page_try_get(space, page_no, &mtr);
216
217 for (i = 0; i < lock_rec_get_n_bits(lock); ++i) {
db82db79 218@@ -4403,6 +4404,7 @@
b4e1fa2c
AM
219
220 putc('\n', file);
221 }
222+ }
223
224 mtr_commit(&mtr);
225 if (UNIV_LIKELY_NULL(heap)) {
db82db79 226@@ -4586,7 +4588,7 @@
b4e1fa2c
AM
227 }
228 }
229
230- if (!srv_print_innodb_lock_monitor) {
231+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
232 nth_trx++;
233 goto loop;
234 }
db82db79 235@@ -4658,8 +4660,8 @@
b4e1fa2c
AM
236
237 nth_lock++;
238
239- if (nth_lock >= 10) {
240- fputs("10 LOCKS PRINTED FOR THIS TRX:"
241+ if (nth_lock >= srv_show_locks_held) {
242+ fputs("TOO MANY LOCKS PRINTED FOR THIS TRX:"
243 " SUPPRESSING FURTHER PRINTS\n",
244 file);
245
db82db79
AM
246--- a/storage/innobase/read/read0read.c
247+++ b/storage/innobase/read/read0read.c
b4e1fa2c
AM
248@@ -357,34 +357,35 @@
249 void
250 read_view_print(
251 /*============*/
252+ FILE* file,
253 const read_view_t* view) /*!< in: read view */
254 {
255 ulint n_ids;
256 ulint i;
257
258 if (view->type == VIEW_HIGH_GRANULARITY) {
259- fprintf(stderr,
260+ fprintf(file,
261 "High-granularity read view undo_n:o %llu\n",
262 (ullint) view->undo_no);
263 } else {
264- fprintf(stderr, "Normal read view\n");
265+ fprintf(file, "Normal read view\n");
266 }
267
268- fprintf(stderr, "Read view low limit trx n:o " TRX_ID_FMT "\n",
269+ fprintf(file, "Read view low limit trx n:o " TRX_ID_FMT "\n",
270 (ullint) view->low_limit_no);
271
272- fprintf(stderr, "Read view up limit trx id " TRX_ID_FMT "\n",
273+ fprintf(file, "Read view up limit trx id " TRX_ID_FMT "\n",
274 (ullint) view->up_limit_id);
275
276- fprintf(stderr, "Read view low limit trx id " TRX_ID_FMT "\n",
277+ fprintf(file, "Read view low limit trx id " TRX_ID_FMT "\n",
278 (ullint) view->low_limit_id);
279
280- fprintf(stderr, "Read view individually stored trx ids:\n");
281+ fprintf(file, "Read view individually stored trx ids:\n");
282
283 n_ids = view->n_trx_ids;
284
285 for (i = 0; i < n_ids; i++) {
286- fprintf(stderr, "Read view trx id " TRX_ID_FMT "\n",
287+ fprintf(file, "Read view trx id " TRX_ID_FMT "\n",
288 (ullint) read_view_get_nth_trx_id(view, i));
289 }
290 }
db82db79
AM
291--- a/storage/innobase/srv/srv0srv.c
292+++ b/storage/innobase/srv/srv0srv.c
adf0fb13 293@@ -83,6 +83,7 @@
b4e1fa2c
AM
294 #include "ha_prototypes.h"
295 #include "trx0i_s.h"
296 #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */
297+#include "read0read.h"
298 #include "mysql/plugin.h"
299 #include "mysql/service_thd_wait.h"
300
adf0fb13 301@@ -188,6 +189,9 @@
b4e1fa2c
AM
302 the checkpoints. */
303 UNIV_INTERN char srv_adaptive_flushing = TRUE;
304
305+UNIV_INTERN ulint srv_show_locks_held = 10;
306+UNIV_INTERN ulint srv_show_verbose_locks = 0;
307+
308 /** Maximum number of times allowed to conditionally acquire
309 mutex before switching to blocking wait on the mutex */
310 #define MAX_MUTEX_NOWAIT 20
734d6226 311@@ -316,6 +320,7 @@
b4e1fa2c
AM
312 /* variable to count the number of pages that were written from buffer
313 pool to the disk */
314 UNIV_INTERN ulint srv_buf_pool_flushed = 0;
315+UNIV_INTERN ulint buf_lru_flush_page_count = 0;
316
317 /** Number of buffer pool reads that led to the
318 reading of a disk page */
734d6226 319@@ -1825,6 +1830,13 @@
b4e1fa2c
AM
320 ulint n_reserved;
321 ibool ret;
322
323+ ulint btr_search_sys_subtotal;
324+ ulint lock_sys_subtotal;
325+ ulint recv_sys_subtotal;
326+
327+ ulint i;
328+ trx_t* trx;
329+
330 mutex_enter(&srv_innodb_monitor_mutex);
331
332 current_time = time(NULL);
734d6226 333@@ -1873,31 +1885,6 @@
b4e1fa2c
AM
334
335 mutex_exit(&dict_foreign_err_mutex);
336
337- /* Only if lock_print_info_summary proceeds correctly,
338- before we call the lock_print_info_all_transactions
339- to print all the lock information. */
340- ret = lock_print_info_summary(file, nowait);
341-
342- if (ret) {
343- if (trx_start) {
344- long t = ftell(file);
345- if (t < 0) {
346- *trx_start = ULINT_UNDEFINED;
347- } else {
348- *trx_start = (ulint) t;
349- }
350- }
351- lock_print_info_all_transactions(file);
352- if (trx_end) {
353- long t = ftell(file);
354- if (t < 0) {
355- *trx_end = ULINT_UNDEFINED;
356- } else {
357- *trx_end = (ulint) t;
358- }
359- }
360- }
361-
362 fputs("--------\n"
363 "FILE I/O\n"
364 "--------\n", file);
734d6226 365@@ -1928,10 +1915,78 @@
b4e1fa2c
AM
366 "BUFFER POOL AND MEMORY\n"
367 "----------------------\n", file);
368 fprintf(file,
369- "Total memory allocated " ULINTPF
370- "; in additional pool allocated " ULINTPF "\n",
371- ut_total_allocated_memory,
372- mem_pool_get_reserved(mem_comm_pool));
373+ "Total memory allocated " ULINTPF
374+ "; in additional pool allocated " ULINTPF "\n",
375+ ut_total_allocated_memory,
376+ mem_pool_get_reserved(mem_comm_pool));
377+ /* Calcurate reserved memories */
378+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
379+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
380+ } else {
381+ btr_search_sys_subtotal = 0;
382+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
383+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
384+ }
385+ }
386+
387+ lock_sys_subtotal = 0;
388+ if (trx_sys) {
389+ mutex_enter(&kernel_mutex);
390+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
391+ while (trx) {
392+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
393+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
394+ }
395+ mutex_exit(&kernel_mutex);
396+ }
397+
398+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
399+ ? mem_heap_get_size(recv_sys->heap) : 0);
400+
401+ fprintf(file,
402+ "Internal hash tables (constant factor + variable factor)\n"
403+ " Adaptive hash index %lu \t(%lu + %lu)\n"
404+ " Page hash %lu (buffer pool 0 only)\n"
405+ " Dictionary cache %lu \t(%lu + %lu)\n"
406+ " File system %lu \t(%lu + %lu)\n"
407+ " Lock system %lu \t(%lu + %lu)\n"
adf0fb13 408+ " Recovery system %lu \t(%lu + %lu)\n",
b4e1fa2c
AM
409+
410+ (ulong) (btr_search_sys
411+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
412+ + btr_search_sys_subtotal,
413+ (ulong) (btr_search_sys
414+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
415+ (ulong) btr_search_sys_subtotal,
416+
417+ (ulong) (buf_pool_from_array(0)->page_hash->n_cells * sizeof(hash_cell_t)),
418+
419+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
420+ + dict_sys->table_id_hash->n_cells
421+ ) * sizeof(hash_cell_t)
422+ + dict_sys->size) : 0),
423+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
424+ + dict_sys->table_id_hash->n_cells
425+ ) * sizeof(hash_cell_t)) : 0),
426+ (ulong) (dict_sys ? (dict_sys->size) : 0),
427+
428+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
429+ + fil_system_hash_nodes()),
430+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
431+ (ulong) fil_system_hash_nodes(),
432+
433+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
434+ + lock_sys_subtotal),
435+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
436+ (ulong) lock_sys_subtotal,
437+
438+ (ulong) (((recv_sys && recv_sys->addr_hash)
439+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
440+ + recv_sys_subtotal),
441+ (ulong) ((recv_sys && recv_sys->addr_hash)
442+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
adf0fb13 443+ (ulong) recv_sys_subtotal);
b4e1fa2c
AM
444+
445 fprintf(file, "Dictionary memory allocated " ULINTPF "\n",
446 dict_sys->size);
447
734d6226 448@@ -1947,6 +2002,16 @@
b4e1fa2c
AM
449 fprintf(file, "%lu read views open inside InnoDB\n",
450 UT_LIST_GET_LEN(trx_sys->view_list));
451
452+ if (UT_LIST_GET_LEN(trx_sys->view_list)) {
453+ read_view_t* view = UT_LIST_GET_LAST(trx_sys->view_list);
454+
455+ if (view) {
456+ fprintf(file, "---OLDEST VIEW---\n");
457+ read_view_print(file, view);
458+ fprintf(file, "-----------------\n");
459+ }
460+ }
461+
462 n_reserved = fil_space_get_n_reserved_extents(0);
463 if (n_reserved > 0) {
464 fprintf(file,
734d6226 465@@ -1990,6 +2055,31 @@
b4e1fa2c
AM
466 srv_n_rows_deleted_old = srv_n_rows_deleted;
467 srv_n_rows_read_old = srv_n_rows_read;
468
469+ /* Only if lock_print_info_summary proceeds correctly,
470+ before we call the lock_print_info_all_transactions
471+ to print all the lock information. */
472+ ret = lock_print_info_summary(file, nowait);
473+
474+ if (ret) {
475+ if (trx_start) {
476+ long t = ftell(file);
477+ if (t < 0) {
478+ *trx_start = ULINT_UNDEFINED;
479+ } else {
480+ *trx_start = (ulint) t;
481+ }
482+ }
483+ lock_print_info_all_transactions(file);
484+ if (trx_end) {
485+ long t = ftell(file);
486+ if (t < 0) {
487+ *trx_end = ULINT_UNDEFINED;
488+ } else {
489+ *trx_end = (ulint) t;
490+ }
491+ }
492+ }
493+
494 fputs("----------------------------\n"
495 "END OF INNODB MONITOR OUTPUT\n"
496 "============================\n", file);
734d6226 497@@ -2033,6 +2123,7 @@
b4e1fa2c
AM
498 = srv_buf_pool_write_requests;
499 export_vars.innodb_buffer_pool_wait_free = srv_buf_pool_wait_free;
500 export_vars.innodb_buffer_pool_pages_flushed = srv_buf_pool_flushed;
501+ export_vars.innodb_buffer_pool_pages_LRU_flushed = buf_lru_flush_page_count;
502 export_vars.innodb_buffer_pool_reads = srv_buf_pool_reads;
734d6226
AM
503 export_vars.innodb_buffer_pool_read_ahead_rnd
504 = stat.n_ra_pages_read_rnd;
db82db79
AM
505--- a/storage/innobase/sync/sync0arr.c
506+++ b/storage/innobase/sync/sync0arr.c
adf0fb13 507@@ -478,7 +478,7 @@
b4e1fa2c
AM
508
509 fprintf(file,
510 "--Thread %lu has waited at %s line %lu"
511- " for %.2f seconds the semaphore:\n",
512+ " for %#.5g seconds the semaphore:\n",
adf0fb13
AM
513 (ulong) os_thread_pf(cell->thread),
514 innobase_basename(cell->file), (ulong) cell->line,
b4e1fa2c 515 difftime(time(NULL), cell->reservation_time));
db82db79
AM
516--- a/storage/innobase/trx/trx0purge.c
517+++ b/storage/innobase/trx/trx0purge.c
11822e22 518@@ -1212,7 +1212,7 @@
b4e1fa2c
AM
519 /*=====================*/
520 {
521 fprintf(stderr, "InnoDB: Purge system view:\n");
522- read_view_print(purge_sys->view);
523+ read_view_print(stderr, purge_sys->view);
524
525 fprintf(stderr, "InnoDB: Purge trx n:o " TRX_ID_FMT
526 ", undo n:o " TRX_ID_FMT "\n",
This page took 0.110783 seconds and 4 git commands to generate.