unclear documentation for get_slave_lag plugin of pt-online-schema-change
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
New
|
Undecided
|
Unassigned |
Bug Description
get_slave_lag should return a function with connection-to-slave argument.
For example:
pt-osc-plugin.pm
package pt_online_
use strict;
sub new {
my ($class, %args) = @_;
my $self = { %args };
return bless $self, $class;
}
sub get_slave_lag {
print "PLUGIN get_slave_lag\n";
my ($self, %args) = @_;
return sub {
print "PLUGIN get_slave_lag call\n";
my ($cxn) = @_;
my $dbh = $cxn->dbh();
my $row = $dbh->selectrow
print "The lag is $row->[0] on $row->[1].\n";
return $row->[0];
};
}
1;
Currently the plugin function is listed in
t/pt-online-
But example is too dump and not including connection to mysql slave.
How to reproduce:
I'm starting master-slave setup from:
https:/ /github. com/ihanick/ mysql-replica
with docker-compose up
docker exec -it mysqlreplica_ master_ 1 bash
apt-get update;apt-get install -y percona-toolkit
using your plugin, adopted to my structure: my $row = $dbh->selectrow _arrayref( q(SELECT unix_timestamp(), @@hostname));
/usr/bin/ pt-online- schema- change --no-check-alter --no-check- replication- filters --execute --chunk- size-limit= 0 --analyze- before- swap --default-engine --plugin= ./pt-osc- plugin. pm --recursion-method dsn=t=test.dsns --max-lag 3 --max-load Threads_running=50 --critical-load Threads_running=500 --alter "FORCE" D=test, t=t,u=root, p=master_ passw0rd
Only single record in dsns table: insert into dsns values (1,1, 'h=172. 19.0.2, u=root, p=slave_ passw0rd' );
table test.t structure is not important, create table t (c int, primary key(c)) engine=innodb;
root@a0702c18b0 89:~# /usr/bin/ pt-online- schema- change --no-check-alter --no-check- replication- filters --execute --chunk- size-limit= 0 --analyze- before- swap --default-engine --plugin= ./pt-osc- plugin. pm --recursion-method dsn=t=test.dsns --max-lag 3 --max-load Threads_running=50 --critical-load