Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 1da062b

Browse files
author
Brice Figureau
committed
Close issue masterzen#5 and possibly masterzen#7
Let's define some default values for some of the innodb paramters.
1 parent 7fb91d2 commit 1da062b

File tree

3 files changed

+241
-2
lines changed

3 files changed

+241
-2
lines changed

mysql-agent

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use Data::Dumper;
3535

3636
# Math::BigInt reverts to perl only
3737
# automatically if GMP is not installed
38-
use Math::BigInt try => 'GMP';
38+
use Math::BigInt lib => 'GMP';
3939

4040
sub new {
4141
bless {}, shift;
@@ -55,6 +55,59 @@ sub parse_innodb_status {
5555
'innodb_tables_in_use' => 0,
5656
'innodb_lock_structs' => 0,
5757
'innodb_lock_wait_secs' => 0,
58+
'pending_normal_aio_reads' => 0,
59+
'pending_normal_aio_writes' => 0,
60+
'pending_ibuf_aio_reads' => 0,
61+
'pending_aio_log_ios' => 0,
62+
'pending_aio_sync_ios' => 0,
63+
'pending_log_flushes' => 0,
64+
'pending_buf_pool_flushes' => 0,
65+
'file_reads' => 0,
66+
'file_writes' => 0,
67+
'file_fsyncs' => 0,
68+
'ibuf_inserts' => 0,
69+
'ibuf_merged' => 0,
70+
'ibuf_merges' => 0,
71+
'log_bytes_written' => 0,
72+
'unflushed_log' => 0,
73+
'log_bytes_flushed' => 0,
74+
'pending_log_writes' => 0,
75+
'pending_chkp_writes' => 0,
76+
'log_writes' => 0,
77+
'pool_size' => 0,
78+
'free_pages' => 0,
79+
'database_pages' => 0,
80+
'modified_pages' => 0,
81+
'pages_read' => 0,
82+
'pages_created' => 0,
83+
'pages_written' => 0,
84+
'queries_inside' => 0,
85+
'queries_queued' => 0,
86+
'read_views' => 0,
87+
'rows_inserted' => 0,
88+
'rows_updated' => 0,
89+
'rows_deleted' => 0,
90+
'rows_read' => 0,
91+
'innodb_transactions' => 0,
92+
'unpurged_txns' => 0,
93+
'history_list' => 0,
94+
'current_transactions' => 0,
95+
'hash_index_cells_total' => 0,
96+
'hash_index_cells_used' => 0,
97+
'total_mem_alloc' => 0,
98+
'additional_pool_alloc' => 0,
99+
'last_checkpoint' => 0,
100+
'uncheckpointed_bytes' => 0,
101+
'ibuf_used_cells' => 0,
102+
'ibuf_free_cells' => 0,
103+
'ibuf_cell_count' => 0,
104+
'adaptive_hash_memory' => 0,
105+
'page_hash_memory' => 0,
106+
'dictionary_cache_memory' => 0,
107+
'file_system_memory' => 0,
108+
'lock_system_memory' => 0,
109+
'recovery_system_memory' => 0,
110+
'thread_hash_memory' => 0
58111
);
59112
my $flushed_to;
60113
my $innodb_lsn;
@@ -63,6 +116,7 @@ sub parse_innodb_status {
63116
my @spin_rounds;
64117
my @os_waits;
65118
my $txn_seen = 0;
119+
my $merged_op_seen = 0;
66120

67121
foreach my $line (@$lines) {
68122
my @row = split(/ +/, $line);
@@ -161,13 +215,27 @@ sub parse_innodb_status {
161215
$status{'ibuf_used_cells'} = $self->tonum($row[2]);
162216
$status{'ibuf_free_cells'} = $self->tonum($row[6]);
163217
$status{'ibuf_cell_count'} = $self->tonum($row[9]);
218+
if ($line =~ m/merges$/) {
219+
# newer innodb plugin
220+
$status{'ibuf_merges'} = $self->tonum($row[10]);
221+
}
164222
}
165223
elsif ($line =~ m/ merged recs, /) {
166224
# 19817685 inserts, 19817684 merged recs, 3552620 merges
167225
$status{'ibuf_inserts'} = $self->tonum($row[0]);
168226
$status{'ibuf_merged'} = $self->tonum($row[2]);
169227
$status{'ibuf_merges'} = $self->tonum($row[5]);
170228
}
229+
elsif ($line =~ m/merged operations:/) {
230+
#merged operations:
231+
# insert 0, delete mark 0, delete 0
232+
$merged_op_seen = 1;
233+
}
234+
elsif ($merged_op_seen && $line =~ m/ insert \d+, delete mark/) {
235+
#merged operations:
236+
# insert 0, delete mark 0, delete 0
237+
$status{'ibuf_inserts'} = $self->tonum($1);
238+
}
171239
elsif ($line =~ m/^Hash table size /) {
172240
# In some versions of InnoDB, the used cells is omitted.
173241
# Hash table size 4425293, used cells 4229064, ....

tests/data/issue5.txt

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
=====================================
2+
110203 14:22:11 INNODB MONITOR OUTPUT
3+
=====================================
4+
Per second averages calculated from the last 4 seconds
5+
-----------------
6+
BACKGROUND THREAD
7+
-----------------
8+
srv_master_thread loops: 38 1_second, 38 sleeps, 2 10_second, 21 background, 21 flush
9+
srv_master_thread log flush and writes: 38
10+
----------
11+
SEMAPHORES
12+
----------
13+
OS WAIT ARRAY INFO: reservation count 9, signal count 9
14+
Mutex spin waits 30, rounds 757, OS waits 1
15+
RW-shared spins 11, rounds 330, OS waits 8
16+
RW-excl spins 0, rounds 0, OS waits 0
17+
Spin rounds per wait: 25.23 mutex, 30.00 RW-shared, 0.00 RW-excl
18+
------------
19+
TRANSACTIONS
20+
------------
21+
Trx id counter B27
22+
Purge done for trx's n:o < B26 undo n:o < 0
23+
History list length 8
24+
LIST OF TRANSACTIONS FOR EACH SESSION:
25+
---TRANSACTION 0, not started, process no 28851, OS thread id 1233471808
26+
MySQL thread id 163515, query id 514448 localhost root
27+
show engine innodb status
28+
--------
29+
FILE I/O
30+
--------
31+
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
32+
I/O thread 1 state: waiting for completed aio requests (log thread)
33+
I/O thread 2 state: waiting for completed aio requests (read thread)
34+
I/O thread 3 state: waiting for completed aio requests (read thread)
35+
I/O thread 4 state: waiting for completed aio requests (read thread)
36+
I/O thread 5 state: waiting for completed aio requests (read thread)
37+
I/O thread 6 state: waiting for completed aio requests (write thread)
38+
I/O thread 7 state: waiting for completed aio requests (write thread)
39+
I/O thread 8 state: waiting for completed aio requests (write thread)
40+
I/O thread 9 state: waiting for completed aio requests (write thread)
41+
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
42+
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
43+
Pending flushes (fsync) log: 0; buffer pool: 0
44+
166 OS file reads, 159 OS file writes, 64 OS fsyncs
45+
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
46+
-------------------------------------
47+
INSERT BUFFER AND ADAPTIVE HASH INDEX
48+
-------------------------------------
49+
Ibuf: size 1, free list len 0, seg size 2, 0 merges
50+
merged operations:
51+
insert 0, delete mark 0, delete 0
52+
discarded operations:
53+
insert 0, delete mark 0, delete 0
54+
Hash table size 553229, node heap has 1 buffer(s)
55+
0.00 hash searches/s, 0.00 non-hash searches/s
56+
---
57+
LOG
58+
---
59+
Log sequence number 1875252
60+
Log flushed up to 1875252
61+
Last checkpoint at 1875252
62+
0 pending log writes, 0 pending chkp writes
63+
36 log i/o's done, 0.00 log i/o's/second
64+
----------------------
65+
BUFFER POOL AND MEMORY
66+
----------------------
67+
Total memory allocated 274726912; in additional pool allocated 0
68+
Dictionary memory allocated 42201
69+
Buffer pool size 16383
70+
Free buffers 16208
71+
Database pages 174
72+
Old database pages 0
73+
Modified db pages 0
74+
Pending reads 0
75+
Pending writes: LRU 0, flush list 0, single page 0
76+
Pages made young 0, not young 0
77+
0.00 youngs/s, 0.00 non-youngs/s
78+
Pages read 152, created 36, written 105
79+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
80+
No buffer pool page gets since the last printout
81+
Pages read ahead 0.00/s, evicted without access 0.00/s
82+
LRU len: 174, unzip_LRU len: 0
83+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
84+
--------------
85+
ROW OPERATIONS
86+
--------------
87+
0 queries inside InnoDB, 0 queries in queue
88+
1 read views open inside InnoDB
89+
Main thread process no. 28851, id 1201736000, state: waiting for server activity
90+
Number of rows inserted 5, updated 1, deleted 0, read 35
91+
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
92+
----------------------------
93+
END OF INNODB MONITOR OUTPUT
94+
============================

tests/test.pl

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ BEGIN
44
require 'mysql-agent';
55
}
66

7-
use Test::More tests => 10;
7+
use Test::More tests => 11;
88
use Data::Dumper;
99

1010
sub readfile
@@ -326,6 +326,83 @@ sub readfile
326326
'ibuf_used_cells' => '1',
327327
'ibuf_free_cells' => '0',
328328
'ibuf_cell_count' => '2',
329+
'file_system_memory' => '0',
330+
'lock_system_memory' => '0',
331+
'recovery_system_memory' => '0',
332+
'thread_hash_memory' => '0',
333+
'adaptive_hash_memory' => '0',
334+
'page_hash_memory' => '0',
335+
'dictionary_cache_memory' => '0',
329336
},
330337
'tests/data/lock.txt'
331338
);
339+
340+
is_deeply(
341+
$innodb_parser->parse_innodb_status(readfile('tests/data/issue5.txt')),
342+
{
343+
'spin_waits' => '41',
344+
'spin_rounds' => '757',
345+
'os_waits' => '1',
346+
'innodb_transactions' => '2855',
347+
'unpurged_txns' => '1',
348+
'history_list' => '8',
349+
'current_transactions' => '1',
350+
'pending_normal_aio_reads' => '0',
351+
'pending_normal_aio_writes' => '0',
352+
'pending_ibuf_aio_reads' => '0',
353+
'pending_aio_log_ios' => '0',
354+
'pending_aio_sync_ios' => '0',
355+
'pending_log_flushes' => '0',
356+
'pending_buf_pool_flushes' => '0',
357+
'file_reads' => '166',
358+
'file_writes' => '159',
359+
'file_fsyncs' => '64',
360+
'ibuf_inserts' => '0',
361+
'ibuf_merged' => '0',
362+
'ibuf_merges' => '0',
363+
'unflushed_log' => '0',
364+
'pending_log_writes' => '0',
365+
'pending_chkp_writes' => '0',
366+
'log_writes' => '36',
367+
'pool_size' => '16383',
368+
'free_pages' => '16208',
369+
'database_pages' => '174',
370+
'modified_pages' => '0',
371+
'pages_read' => '0',
372+
'pages_created' => '0',
373+
'pages_written' => '0',
374+
'queries_inside' => '0',
375+
'queries_queued' => '0',
376+
'read_views' => '1',
377+
'rows_inserted' => '5',
378+
'rows_updated' => '1',
379+
'rows_deleted' => '0',
380+
'rows_read' => '35',
381+
'log_bytes_written' => '1875252',
382+
'log_bytes_flushed' => '1875252',
383+
'locked_transactions' => '0',
384+
'active_transactions' => '0',
385+
'active_transactions' => '0',
386+
'hash_index_cells_total' => '553229',
387+
'hash_index_cells_used' => '0',
388+
'total_mem_alloc' => '274726912',
389+
'additional_pool_alloc' => '0',
390+
'last_checkpoint' => '1875252',
391+
'uncheckpointed_bytes' => '0',
392+
'ibuf_used_cells' => '1',
393+
'ibuf_free_cells' => '0',
394+
'ibuf_cell_count' => '2',
395+
'adaptive_hash_memory' => '0',
396+
'page_hash_memory' => '0',
397+
'dictionary_cache_memory' => '0',
398+
'file_system_memory' => '0',
399+
'lock_system_memory' => '0',
400+
'recovery_system_memory' => '0',
401+
'thread_hash_memory' => '0',
402+
'innodb_locked_tables' => '0',
403+
'innodb_lock_wait_secs' => '0',
404+
'innodb_lock_structs' => '0',
405+
'innodb_tables_in_use' => '0',
406+
},
407+
'tests/data/issue5.txt'
408+
);

0 commit comments

Comments
 (0)