mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Merge pull request #190 from guriandoro/pt-stalk-collect-prepared-statements-LP1642750
pt stalk collect prepared statements lp1642750 (PT-90)
This commit is contained in:
13
bin/pt-stalk
13
bin/pt-stalk
@@ -833,8 +833,6 @@ collect() {
|
||||
else
|
||||
log "Could not find the MySQL error log"
|
||||
fi
|
||||
|
||||
|
||||
if [ "${mysql_version}" '>' "5.1" ]; then
|
||||
local mutex="SHOW ENGINE INNODB MUTEX"
|
||||
else
|
||||
@@ -960,6 +958,10 @@ collect() {
|
||||
ps_locks_transactions "$d/$p-ps-locks-transactions"
|
||||
fi
|
||||
|
||||
if [ "${mysql_version}" '>' "5.6" ]; then
|
||||
(echo $ts; ps_prepared_statements) >> "$d/$p-prepared-statements" &
|
||||
fi
|
||||
|
||||
slave_status "$d/$p-slave-status" "${mysql_version}"
|
||||
|
||||
curr_time=$(date +'%s')
|
||||
@@ -1126,6 +1128,13 @@ ps_locks_transactions() {
|
||||
|
||||
}
|
||||
|
||||
ps_prepared_statements() {
|
||||
$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"
|
||||
}
|
||||
|
||||
slave_status() {
|
||||
local outfile=$1
|
||||
local mysql_version=$2
|
||||
|
@@ -101,8 +101,6 @@ collect() {
|
||||
else
|
||||
log "Could not find the MySQL error log"
|
||||
fi
|
||||
|
||||
|
||||
# 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
|
||||
@@ -252,6 +250,10 @@ collect() {
|
||||
ps_locks_transactions "$d/$p-ps-locks-transactions"
|
||||
fi
|
||||
|
||||
if [ "${mysql_version}" '>' "5.6" ]; then
|
||||
(echo $ts; ps_prepared_statements) >> "$d/$p-prepared-statements" &
|
||||
fi
|
||||
|
||||
slave_status "$d/$p-slave-status" "${mysql_version}"
|
||||
|
||||
curr_time=$(date +'%s')
|
||||
@@ -430,6 +432,13 @@ ps_locks_transactions() {
|
||||
|
||||
}
|
||||
|
||||
ps_prepared_statements() {
|
||||
$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"
|
||||
}
|
||||
|
||||
slave_status() {
|
||||
local outfile=$1
|
||||
local mysql_version=$2
|
||||
|
@@ -528,9 +528,56 @@ SKIP: {
|
||||
);
|
||||
}
|
||||
|
||||
# ###########################################################################
|
||||
# Test report about performance schema prepared_statements_instances in MySQL 5.7+
|
||||
# ###########################################################################
|
||||
|
||||
cleanup();
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Only test on mysql 5.7" if ( $sandbox_version lt '5.7' );
|
||||
|
||||
sub start_thread_1642750 {
|
||||
# this must run in a thread because we need to have an active session
|
||||
# with prepared statements
|
||||
my ($dsn_opts) = @_;
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
$sb->load_file('master', "t/pt-stalk/samples/issue-1642750.sql");
|
||||
}
|
||||
my $thr = threads->create('start_thread_1642750', $dsn_opts);
|
||||
$thr->detach();
|
||||
threads->yield();
|
||||
|
||||
my $cmd = "$trunk/bin/pt-stalk --no-stalk --iterations=1 --host=127.0.0.1 --port=12345 --user=msandbox "
|
||||
. "--password=msandbox --sleep 0 --run-time=10 --dest $dest --log $log_file --pid $pid_file "
|
||||
. "--defaults-file=$cnf >$log_file 2>&1";
|
||||
|
||||
system($cmd);
|
||||
sleep 15;
|
||||
PerconaTest::kill_program(pid_file => $pid_file);
|
||||
|
||||
$output = `cat $dest/*-prepared-statements 2>/dev/null`;
|
||||
like(
|
||||
$output,
|
||||
qr/ STATEMENT_NAME: rand_statement/,
|
||||
"MySQL 5.7 prepared statement: rand_statement"
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/ STATEMENT_NAME: abs_statement/,
|
||||
"MySQL 5.7 prepared statement: abs_statement"
|
||||
);
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
||||
|
||||
cleanup();
|
||||
diag(`rm -rf $dest 2>/dev/null`);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
|
11
t/pt-stalk/samples/issue-1642750.sql
Normal file
11
t/pt-stalk/samples/issue-1642750.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
/* Prepare two statements*/
|
||||
|
||||
SET @random_statement_prepare = 'SELECT RAND() AS rand';
|
||||
PREPARE rand_statement FROM @random_statement_prepare;
|
||||
|
||||
SET @absolute_value_statement_prepare = 'SELECT ABS(?) AS abs_A';
|
||||
PREPARE abs_statement FROM @absolute_value_statement_prepare;
|
||||
|
||||
/* Wait to let pt-stalk to collect the data and find these prepare statements */
|
||||
SELECT SLEEP(11);
|
||||
|
Reference in New Issue
Block a user