diff --git a/bin/pt-stalk b/bin/pt-stalk index 9118b13b..c6d72ec4 100755 --- a/bin/pt-stalk +++ b/bin/pt-stalk @@ -1064,6 +1064,27 @@ tokudb_status() { >> "$d/$p-tokudbstatus$n" || rm -f "$d/$p-tokudbstatus$n" } +innodb_status() { + local n=$1 + + local innostat="" + + $CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \ + >> "$d/$p-innodbstatus$n" + grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || { + if [ -d /proc -a -d /proc/$mysqld_pid ]; then + for fd in /proc/$mysqld_pid/fd/*; do + file $fd | grep deleted >/dev/null && { + grep 'INNODB' $fd >/dev/null && { + cat $fd > "$d/$p-innodbstatus$n" + break + } + } + done + fi + } +} + ps_locks_transactions() { local outfile=$1 @@ -1091,27 +1112,6 @@ ps_locks_transactions() { } -innodb_status() { - local n=$1 - - local innostat="" - - $CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \ - >> "$d/$p-innodbstatus$n" - grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || { - if [ -d /proc -a -d /proc/$mysqld_pid ]; then - for fd in /proc/$mysqld_pid/fd/*; do - file $fd | grep deleted >/dev/null && { - grep 'INNODB' $fd >/dev/null && { - cat $fd > "$d/$p-innodbstatus$n" - break - } - } - done - fi - } -} - # ########################################################################### # End collect package # ########################################################################### diff --git a/lib/bash/collect.sh b/lib/bash/collect.sh index 85b9c141..45dbc1f9 100644 --- a/lib/bash/collect.sh +++ b/lib/bash/collect.sh @@ -102,6 +102,8 @@ collect() { log "Could not find the MySQL error log" fi + ps_locks_transactions "$d/$p-ps-locks-transactions" + # Get a sample of these right away, so we can get these without interaction # with the other commands we're about to run. if [ "${mysql_version}" '>' "5.1" ]; then @@ -389,6 +391,33 @@ innodb_status() { } } +ps_locks_transactions() { + local outfile=$1 + + mysql -e 'select @@performance_schema' | grep "1" &>/dev/null + + if [ $? -eq 0 ]; then + local status="select t.processlist_id, ml.* from performance_schema.metadata_locks ml join performance_schema.threads t on (ml.owner_thread_id=t.thread_id)\G" + echo -e "\n$status\n" >> $outfile + $CMD_MYSQL $EXT_ARGV -e "$status" >> $outfile + + local status="select t.processlist_id, th.* from performance_schema.table_handles th left join performance_schema.threads t on (th.owner_thread_id=t.thread_id)\G" + echo -e "\n$status\n" >> $outfile + $CMD_MYSQL $EXT_ARGV -e "$status" >> $outfile + + local status="select t.processlist_id, et.* from performance_schema.events_transactions_current et join performance_schema.threads t using(thread_id)\G" + echo -e "\n$status\n" >> $outfile + $CMD_MYSQL $EXT_ARGV -e "$status" >> $outfile + + local status="select t.processlist_id, et.* from performance_schema.events_transactions_history_long et join performance_schema.threads t using(thread_id)\G" + echo -e "\n$status\n" >> $outfile + $CMD_MYSQL $EXT_ARGV -e "$status" >> $outfile + else + echo "Performance schema is not enabled" >> $outfile + fi + +} + # ########################################################################### # End collect package # ###########################################################################