Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mastering InnoDB Diagnostics Harrison Fisk Senior Principal Technical Support Engineer.

Similar presentations


Presentation on theme: "Mastering InnoDB Diagnostics Harrison Fisk Senior Principal Technical Support Engineer."— Presentation transcript:

1 Mastering InnoDB Diagnostics Harrison Fisk Senior Principal Technical Support Engineer

2 Overview Lots of information Hard to understand Easy to get overwhelmed Hard to figure out what is useful Two methods for troubleshooting Symptom based What we will be doing today Data based

3 Information Sources

4 Sources MySQL info SHOW ENGINE INNODB STATUS InnoDB monitors SHOW GLOBAL STATUS INFORMATION_SCHEMA tables SHOW PROCESSLIST SHOW MUTEX STATUS OS info vmstat / iostat or Performance Monitor Gdb ( Poor mans profiler (PMP)) OS specific tools

5 SHOW INNODB STATUS Be careful of truncation innodb_status_file Table monitors Ensure enough time has passed Exact format varies InnoDB built-in InnoDB plugin XtraDB

6 Data Dictionary

7 Problems InnoDB: Error: table test/parent already exists in InnoDB internal InnoDB: data dictionary. Have you deleted the.frm file InnoDB: and not used DROP TABLE? InnoDB: Cannot find table test/child2 from the internal data dictionary InnoDB: of InnoDB though the.frm file for the table exists. Maybe you InnoDB: have deleted and recreated InnoDB data files but have forgotten InnoDB: to delete the corresponding.frm files of InnoDB tables? Various errors about not being in sync Can't drop and/or create tables or databases Example errors:

8 Diagnostics InnoDB table monitor Dumps InnoDB data dictionary Output to error log CREATE TABLE innodb_table_monitor (id int) ENGINE=innodb;

9 Interpreting Ignore system tables Named SYS_ Ignore hidden fields from InnoDB DB_ROW_ID DB_TRX_ID DB_ROLL_PTR Ignore hidden indexes GEN_CLUST_INDEX

10 Solutions Ensure.frm matches InnoDB Create.frm as needed Create another table with same structure Copy.frm to the name of the table Drop orphaned.frm files If not in InnoDB Remove them

11 Crashing

12 Problem mysqld Crash Signal 11 Segfault Signal 6 Abort InnoDB loves this one May not actually notice immediately mysqld_safe restarts

13 Diagnostics Error log Hopefully it has info in it Core file Not enabled by default OS often restricts setuid cores /proc/sys/fs/suid_dumpable coreadm General log When all else fails

14 Interpreting Error log Error log Look for signal type Signal 11 Signal 6 Backtrace May or may not be present OS Version In 5.0 and before you need to resolve it resolve_stack_dump Search bug system for function names

15 Interpreting Cores Must be enabled Memory image produced Requires exactly the same binary and libraries With rpm ensure debuginfo is installed Non-stripped binaries Load with gdb thread apply all bt Use PMP to summarize if needed Solaris: pstack Windows: Minidump/DrWatson/Windbg

16 Solutions Find cause of the crash InnoDB doing on purpose Real crash Find query causing problem Stop doing it Report bug to us Upgrade Lots of bugs fixed each release

17 Locking

18 Problems Deadlocks Real deadlocks ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction Lock wait timeouts ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction General locking slowness

19 Diagnostics SHOW INNODB STATUS TRANSACTIONS section innodb_lock_monitor table Changes output of SHOW INNODB STATUS INFORMATION_SCHEMA INNODB_LOCKS INNODB_LOCK_WAITS SHOW GLOBAL STATUS LIKE 'innodb_row_lock%'

20 Interpreting Find what lock is needed Who is holding conflicting lock Look for type of lock X (exclusive) S (shared) Relatively rare Others Look for what the lock is on Table (primary key) Index

21 Solutions Fix queries to reduce locks Shared locks Find source Eliminate Upgrade to 5.1 run in read committed Remove source of lock AUTO-INC Upgrade to 5.1 innodb_autoinc_lock = 2? Long running transactions

22 Performance

23 Overview Lots of potential performance issues Disk I/O Log files Table space CPU Too many rows being read Thread thrashing Gather lots of information up front Big picture, not details first Ensure it is during “problem” time

24 Disk: Log files Many small serialized synchronous writes InnoDB redo log writes bottleneck fdatasync () is expensive in many setups innodb_flush_log_at_trx_commit 1 Safest, sync every commit 2 Write every commit 0 Write only every second

25 Diagnostics SHOW INNODB STATUS State of transactions COMMITTED IN MEMORY PREPARED FILE I/O Pending flushes (fsync) log fsyncs/s iostat Number of write operations ( w/s ) await and/or svctm

26 Solutions InnoDB plugin group commit Change innodb_flush_log_at_trx_commit Better disks BBU write cache Faster writes

27 Disk: Tablespace Reading and writing your actual tables and indexes More common with very large tables Compare to buffer pool size Sometimes caused by read ahead in InnoDB

28 Diagnostics SHOW INNODB STATUS Buffer pool hit rate Watch absolute values too FILE I/O Reads/s Avg bytes/read shows reada head Pending reads Read ahead Pages read ahead/evicted without access iostat avgqu-sz await

29 Solutions Optimize queries Increase innodb_buffer_pool_size New LRU algorithm in InnoDB plugin Tune/disable readahead In plugin, can be tuned In non-plugin Use gdb hack set srv_startup_is_before_trx_rollback_phase=1 Buy better disks

30 CPU: Lots of Rows Bad queries can read lots of rows Or lots and lots of smaller queries Data fully cached Lots of buffer pool reading Often smaller dataset Eventually will bottleneck InnoDB on CPU

31 Diagnostics SHOW INNODB STATUS ROW OPERATIONS Reads/s SHOW GLOBAL STATUS LIKE 'Handler%' Type of row operations going on Slow query log log-queries-not-using-indexes

32 Solutions Fix your queries Ensure proper index usage Do less queries External caching Scale reads Replication

33 CPU: Thread Thrashing InnoDB can have issues at high concurrency Later releases help reduce this dramatically InnoDB plugin Further versions XtraDB MySQL 5.5

34 Diagnostics SHOW INNODB STATUS Lots of queued threads TRANSACTIONS Queries in queue ROW OPERATIONS reads/s is “low” vmstat Very high CPU usage Lots of “cs” context switches SHOW MUTEX STATUS

35 Solutions innodb_thread_concurrency Very high or 0 works best until it doesn't Sometimes very low works best A bit of a black art in tuning innodb_concurrency_tickets Size based on number of rows being touched Use newer version Lots of work to help this in InnoDB Plugin

36 Questions?

37 The presentation is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

38


Download ppt "Mastering InnoDB Diagnostics Harrison Fisk Senior Principal Technical Support Engineer."

Similar presentations


Ads by Google