From b3776a25a8907a03b96260bade9ca55c4de7a2e8 Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Thu, 23 Feb 2017 18:00:00 -0300 Subject: [PATCH] PT-81 Collect information about locks and transactions using P_S --- bin/pt-stalk | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bin/pt-stalk b/bin/pt-stalk index c0b07dc8..f0e6b8b2 100755 --- a/bin/pt-stalk +++ b/bin/pt-stalk @@ -832,6 +832,8 @@ collect() { log "Could not find the MySQL error log" fi + ps_locks_transactions "$d/$p-ps-locks-transactions" + if [ "${mysql_version}" '>' "5.1" ]; then local mutex="SHOW ENGINE INNODB MUTEX" else @@ -1062,6 +1064,29 @@ tokudb_status() { >> "$d/$p-tokudbstatus$n" || rm -f "$d/$p-tokudbstatus$n" } +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, 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 + +} + innodb_status() { local n=$1