mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 00:43:58 +00:00
PS-2033, proof of concept (#540)
This commit is contained in:
18
bin/pt-stalk
18
bin/pt-stalk
@@ -979,7 +979,7 @@ collect_mysql_data_loop() {
|
||||
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SHOW FULL PROCESSLIST\G") \
|
||||
>> "$d/$p-processlist" &
|
||||
if [ "$have_lock_waits_table" ]; then
|
||||
(echo $ts; lock_waits) >>"$d/$p-lock-waits" &
|
||||
(echo $ts; lock_waits "$d/lock_waits.running") >>"$d/$p-lock-waits" &
|
||||
(echo $ts; transactions) >>"$d/$p-transactions" &
|
||||
fi
|
||||
|
||||
@@ -988,7 +988,7 @@ collect_mysql_data_loop() {
|
||||
fi
|
||||
|
||||
if [ "${mysql_version}" '>' "5.6" ]; then
|
||||
(echo $ts; ps_prepared_statements) >> "$d/$p-prepared-statements" &
|
||||
(echo $ts; ps_prepared_statements "$d/prepared_statements.isrunnning") >> "$d/$p-prepared-statements" &
|
||||
fi
|
||||
|
||||
slave_status "$d/$p-slave-status" "${mysql_version}"
|
||||
@@ -1089,6 +1089,11 @@ open_tables() {
|
||||
}
|
||||
|
||||
lock_waits() {
|
||||
local flag_file=$1
|
||||
if test -f "$flag_file"; then
|
||||
echo "Lock collection already running, skipping this iteration"
|
||||
else
|
||||
touch "$flag_file"
|
||||
local sql1="SELECT SQL_NO_CACHE
|
||||
CONCAT('thread ', b.trx_mysql_thread_id, ' from ', p.host) AS who_blocks,
|
||||
IF(p.command = \"Sleep\", p.time, 0) AS idle_in_trx,
|
||||
@@ -1119,6 +1124,8 @@ lock_waits() {
|
||||
LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST AS p ON p.id = b.trx_mysql_thread_id
|
||||
ORDER BY wait_time DESC\G"
|
||||
$CMD_MYSQL $EXT_ARGV -e "$sql2"
|
||||
rm "$flag_file"
|
||||
fi
|
||||
}
|
||||
|
||||
transactions() {
|
||||
@@ -1200,10 +1207,17 @@ ps_locks_transactions() {
|
||||
}
|
||||
|
||||
ps_prepared_statements() {
|
||||
local flag_file=$1
|
||||
if test -f "$flag_file"; then
|
||||
echo "Prepared statements collection already running, skipping this iteration"
|
||||
else
|
||||
touch "$flag_file"
|
||||
$CMD_MYSQL $EXT_ARGV -e "SELECT t.processlist_id, pse.* \
|
||||
FROM performance_schema.prepared_statements_instances pse \
|
||||
JOIN performance_schema.threads t \
|
||||
ON (pse.OWNER_THREAD_ID=t.thread_id)\G"
|
||||
rm "$flag_file"
|
||||
fi
|
||||
}
|
||||
|
||||
slave_status() {
|
||||
|
@@ -266,7 +266,7 @@ collect_mysql_data_loop() {
|
||||
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SHOW FULL PROCESSLIST\G") \
|
||||
>> "$d/$p-processlist" &
|
||||
if [ "$have_lock_waits_table" ]; then
|
||||
(echo $ts; lock_waits) >>"$d/$p-lock-waits" &
|
||||
(echo $ts; lock_waits "$d/lock_waits.running") >>"$d/$p-lock-waits" &
|
||||
(echo $ts; transactions) >>"$d/$p-transactions" &
|
||||
fi
|
||||
|
||||
@@ -275,7 +275,7 @@ collect_mysql_data_loop() {
|
||||
fi
|
||||
|
||||
if [ "${mysql_version}" '>' "5.6" ]; then
|
||||
(echo $ts; ps_prepared_statements) >> "$d/$p-prepared-statements" &
|
||||
(echo $ts; ps_prepared_statements "$d/prepared_statements.isrunnning") >> "$d/$p-prepared-statements" &
|
||||
fi
|
||||
|
||||
slave_status "$d/$p-slave-status" "${mysql_version}"
|
||||
@@ -387,6 +387,11 @@ open_tables() {
|
||||
}
|
||||
|
||||
lock_waits() {
|
||||
local flag_file=$1
|
||||
if test -f "$flag_file"; then
|
||||
echo "Lock collection already running, skipping this iteration"
|
||||
else
|
||||
touch "$flag_file"
|
||||
local sql1="SELECT SQL_NO_CACHE
|
||||
CONCAT('thread ', b.trx_mysql_thread_id, ' from ', p.host) AS who_blocks,
|
||||
IF(p.command = \"Sleep\", p.time, 0) AS idle_in_trx,
|
||||
@@ -417,6 +422,8 @@ lock_waits() {
|
||||
LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST AS p ON p.id = b.trx_mysql_thread_id
|
||||
ORDER BY wait_time DESC\G"
|
||||
$CMD_MYSQL $EXT_ARGV -e "$sql2"
|
||||
rm "$flag_file"
|
||||
fi
|
||||
}
|
||||
|
||||
transactions() {
|
||||
@@ -498,10 +505,21 @@ ps_locks_transactions() {
|
||||
}
|
||||
|
||||
ps_prepared_statements() {
|
||||
# PS-2033:
|
||||
# If no flag file exists, create it, then collect data
|
||||
# After data collected, remove the file
|
||||
# If flag file exists, skip current iteration
|
||||
local flag_file=$1
|
||||
if test -f "$flag_file"; then
|
||||
echo "Prepared statements collection already running, skipping this iteration"
|
||||
else
|
||||
touch "$flag_file"
|
||||
$CMD_MYSQL $EXT_ARGV -e "SELECT t.processlist_id, pse.* \
|
||||
FROM performance_schema.prepared_statements_instances pse \
|
||||
JOIN performance_schema.threads t \
|
||||
ON (pse.OWNER_THREAD_ID=t.thread_id)\G"
|
||||
rm "$flag_file"
|
||||
fi
|
||||
}
|
||||
|
||||
slave_status() {
|
||||
|
Reference in New Issue
Block a user