Compare commits

..

1 Commits

Author SHA1 Message Date
Carlos Salguero
1352db81b6 PT-1398 Updated way of getting MySQL PID 2021-09-30 15:51:47 -03:00
4 changed files with 44 additions and 88 deletions

View File

@@ -1,31 +1,9 @@
Changelog for Percona Toolkit
v3.3.2 WIP release date not set yet
* Improvement PT-1417: Inconsistent creation of toolkit tables
* Fixed bug PT-1627: pt-mysql-summary doesn't verify which version of jemalloc is in use
* Fixed bug PT-1747: pt-online-schema-change: metadata lock can break database for rebuild_constraints
* Improvement PT-1800: PTDEBUG=1 exposes passwords
* Fixed bug PT-1900: pt-query-digest not hiding parameter properly sometimes when parameter=binary
* Improvement PT-1940: ptsoc dropswap with mysql8: revise rejection (Thanks duxthefux)
* Fixed bug PT-1953: pt-summary typo: Memory mamagement.
* Fixed bug PT-1959: go part of the toolkit still has the version 3.3.0
* Improvement PT-1974: Support fingerprinting for --print in pt-kill (Thanks Iwo Panowicz)
* Fixed bug PT-1966: Fixed test (Thanks @yoku0825)
* Fixed bug PT-1965: pt-stalk --mysql-only doesn't collect mysqladmin outputs (Thanks Sergey Kuzmichev)
* Fixed bug PT-1966: Test no_drop_no_swap for the pt-online-schema-change is broken (Thanks Tsubasa Tanaka)
* Fixed bug PT-1974: Support fingerprinting for --print in pt-kill
* Fixed bug PT-1983: pt-summary missing one DIMM
* Admin task PT-2009: Update Go Lang dependencies
* Admin task PT-2011: Make build reproducible
v3.3.1 release 2021-04-28
* Fixed bug PT-716 : pt-summary reports wrong memory size
* Fixed bug PT-1914: Column data lost when 'Generated' is in the column comment
* Fixed bug PT-1919: pt-online-schema change drop_swap can lose triggers. (Thanks Bob)
* Fixed bug PT-1943: BEFORE triggers are dropped after pt-online-schema-change run
v3.3.0 release 2021-01-14
* Improvement PT-1940: Added mysql version check for bug fix introduced in 8.0.14 (Thanks duxthefux)
* Fixed bug PT-1919: pt-online-schema change drop_swap can lose triggers. (Thanks Bob)
* Fixed bug PT-1914: Column data lost when 'Generated' is in the column comment
@@ -34,17 +12,17 @@ v3.3.0 release 2021-01-14
v3.3.0 release 2021-01-14
* Fixed bug PT-169 : pt-online-schema-change FKs error handling.
* Fixed bug PT-1518: pt-table-checksum gives error CRC32. (Thanks @ovidiustanila)
* Fixed bug PT-1822: pt-mongodb-summary fails on standalone mongodb instances
* Fixed bug PT-1829: pt-heartbeat doesn't reconnect for check-read-only
* Improvement PT-1836: Review and consider lintian reported issues
* Improvement PT-1851: Backslashes missing from documentation
* Improvement PT-1853: Added --no-check-foreing-keys to pt-osc
* Fixed bug PT-1857: pt-heartbeat cannot reconnect.
* Fixed bug PT-1859: pt-pg-summary fails for Postgres12 (Thanks Sergey Kuzmichev)
* Fixed bug PT-1881: pt-upgrade fails when query including format strings and SQL errors is given (Thanks Nayuta Yanagisawa)
* Fixed bug PT-169 : pt-online-schema-change FKs error handling.
* Fixed bug PT-1892: pt-summary says sshd not running
* Fixed bug PT-1881: pt-upgrade fails when query including format strings and SQL errors is given (Thanks Nayuta Yanagisawa)
* Fixed bug PT-1859: pt-pg-summary fails for Postgres12 (Thanks Sergey Kuzmichev)
* Improvement PT-1853: Added --no-check-foreing-keys to pt-osc
* Improvement PT-1851: Backslashes missing from documentation
* Improvement PT-1836: Review and consider lintian reported issues
* Fixed bug PT-1829: pt-heartbeat doesn't reconnect for check-read-only
* Fixed bug PT-1822: pt-mongodb-summary fails on standalone mongodb instances
* Fixed bug PT-1518: pt-table-checksum gives error CRC32. (Thanks @ovidiustanila)
v3.2.0 release 2020-04-23

View File

@@ -822,7 +822,7 @@ collect() {
local mysql_version="$(awk '/^version[^_]/{print substr($2,1,3)}' "$d/$p-variables")"
local mysql_error_log="$(awk '/^log_error /{print $2}' "$d/$p-variables")"
local mysql_error_log="$(awk '/^log_error/{print $2}' "$d/$p-variables")"
if [ -z "$mysql_error_log" -a "$mysqld_pid" ]; then
mysql_error_log="$(ls -l /proc/$mysqld_pid/fd | awk '/ 2 ->/{print $NF}')"
fi
@@ -833,10 +833,10 @@ collect() {
tail -f "$mysql_error_log" >"$d/$p-log_error" &
tail_error_log_pid=$!
$CMD_MYSQLADMIN $EXT_ARGV
$CMD_MYSQLADMIN $EXT_ARGV debug
else
log "Could not find the MySQL error log"
fi
fi
if [ "${mysql_version}" '>' "5.1" ]; then
local mutex="SHOW ENGINE INNODB MUTEX"
else
@@ -869,12 +869,7 @@ collect() {
local strace_pid=$!
fi
local cnt=$(($OPT_RUN_TIME / $OPT_SLEEP_COLLECT))
$CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
local mysqladmin_pid=$!
if [ ! "$OPT_MYSQL_ONLY" ]; then
if [ ! "$OPT_MYSQL_ONLY" ]; then
ps -eaF >> "$d/$p-ps" &
top -bn${OPT_RUN_TIME} >> "$d/$p-top" &
@@ -887,9 +882,10 @@ collect() {
if [ "$CMD_DMESG" ]; then
local UPTIME=`cat /proc/uptime | awk '{ print $1 }'`
local START_TIME=$(echo "$UPTIME 60" | awk '{print ($1 - $2)}')
$CMD_DMESG | perl -ne 'm/\[\s*(\d+)\./; if ($1 > '${START_TIME}') { print }' >> "$d/$p-dmesg" &
$CMD_DMESG | perl -ne 'm/\[\s*(\d+)\./; if ($1 > '${START_TIME}') { print }' >> "$d/$p-dmesg" &
fi
local cnt=$(($OPT_RUN_TIME / $OPT_SLEEP_COLLECT))
if [ "$CMD_VMSTAT" ]; then
$CMD_VMSTAT $OPT_SLEEP_COLLECT $cnt >> "$d/$p-vmstat" &
$CMD_VMSTAT $OPT_RUN_TIME 2 >> "$d/$p-vmstat-overall" &
@@ -902,7 +898,10 @@ collect() {
$CMD_MPSTAT -P ALL $OPT_SLEEP_COLLECT $cnt >> "$d/$p-mpstat" &
$CMD_MPSTAT -P ALL $OPT_RUN_TIME 1 >> "$d/$p-mpstat-overall" &
fi
fi
$CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
local mysqladmin_pid=$!
fi
local have_lock_waits_table=""
$CMD_MYSQL $EXT_ARGV -e "SHOW TABLES FROM INFORMATION_SCHEMA" \
@@ -917,7 +916,7 @@ collect() {
local ps_instrumentation_enabled=$($CMD_MYSQL $EXT_ARGV -e 'SELECT ENABLED FROM performance_schema.setup_instruments WHERE NAME = "transaction";' \
| sed "2q;d" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
if [ !$ps_instrumentation_enabled = "yes" ]; then
if [ $ps_instrumentation_enabled != "yes" ]; then
log "Performance Schema instrumentation is disabled"
fi
@@ -956,12 +955,12 @@ collect() {
(echo $ts; df -k) >> "$d/$p-df" &
(echo $ts; netstat -antp) >> "$d/$p-netstat" &
(echo $ts; netstat -s) >> "$d/$p-netstat_s" &
fi
($CMD_MYSQL $EXT_ARGV -e "SHOW FULL PROCESSLIST\G") \
fi
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SHOW FULL PROCESSLIST\G") \
>> "$d/$p-processlist" &
if [ "$have_lock_waits_table" ]; then
(lock_waits) >>"$d/$p-lock-waits" &
(transactions) >>"$d/$p-transactions" &
(echo $ts; lock_waits) >>"$d/$p-lock-waits" &
(echo $ts; transactions) >>"$d/$p-transactions" &
fi
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes" ]; then
@@ -969,10 +968,10 @@ collect() {
fi
if [ "${mysql_version}" '>' "5.6" ]; then
(ps_prepared_statements) >> "$d/$p-prepared-statements" &
(echo $ts; ps_prepared_statements) >> "$d/$p-prepared-statements" &
fi
slave_status "$d/$p-slave-status" "${mysql_version}"
slave_status "$d/$p-slave-status" "${mysql_version}"
curr_time=$(date +'%s')
done
@@ -1077,7 +1076,7 @@ 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"
}
}
transactions() {
$CMD_MYSQL $EXT_ARGV -e "SELECT SQL_NO_CACHE * FROM INFORMATION_SCHEMA.INNODB_TRX ORDER BY trx_id\G"
@@ -1126,8 +1125,8 @@ rocksdb_status() {
}
ps_locks_transactions() {
local outfile=$1
local outfile=$1
$CMD_MYSQL $EXT_ARGV -e 'select @@performance_schema' | grep "1" &>/dev/null
if [ $? -eq 0 ]; then
@@ -1163,27 +1162,28 @@ slave_status() {
local outfile=$1
local mysql_version=$2
local sql="SHOW SLAVE STATUS\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
if [ "${mysql_version}" '>' "5.6" ]; then
if [ "${mysql_version}" '<' "5.7" ]; then
local sql="SHOW SLAVE STATUS\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
else
local sql="SELECT * FROM performance_schema.replication_connection_configuration JOIN performance_schema.replication_applier_configuration USING(channel_name)\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="SELECT * FROM performance_schema.replication_connection_status\G"
sql="SELECT * FROM replication_connection_status\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="SELECT * FROM performance_schema.replication_applier_status JOIN performance_schema.replication_applier_status_by_coordinator USING(channel_name)\G"
sql="SELECT * FROM replication_applier_status JOIN replication_applier_status_by_coordinator USING(channel_name)\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
fi
}
collect_mysql_variables() {
local outfile=$1
local outfile=$1
local sql="SHOW GLOBAL VARIABLES"
echo -e "\n$sql\n" >> $outfile
@@ -1192,11 +1192,11 @@ collect_mysql_variables() {
sql="select * from performance_schema.variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.user_variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.status_by_thread order by thread_id, variable_name; "
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile

23
go.mod
View File

@@ -28,34 +28,11 @@ require (
require (
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/snappy v0.0.2-0.20190904063534-ff6b7dc882cf // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/klauspost/compress v1.10.10 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.0.2 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
k8s.io/apimachinery v0.18.6 // indirect
k8s.io/klog v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect
)

View File

@@ -52,7 +52,8 @@ collect() {
local mysqld_pid=""
# Get pidof mysqld.
if [ ! "$OPT_MYSQL_ONLY" ]; then
mysqld_pid=$(_pidof mysqld | awk '{print $1; exit;}')
port=$(mysql -ss -e 'SELECT @@port')
mysqld_pid=$(lsof -i ":${port}" | grep -i listen | cut -f 3 -d" ")
fi
# Get memory allocation info before anything else.