unclear documentation for get_slave_lag plugin of pt-online-schema-change

Bug #1735111 reported by Nickolay Ihalainen
6
This bug affects 1 person
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_schema_change_plugin;

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_arrayref(q(SELECT 2, @@hostname));
    print "The lag is $row->[0] on $row->[1].\n";
    return $row->[0];
  };
}

1;

Currently the plugin function is listed in
t/pt-online-schema-change/samples/plugins/all_hooks.pm
But example is too dump and not including connection to mysql slave.

Tags: i213209
Revision history for this message
Nickolay Ihalainen (ihanick) wrote :

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@a0702c18b089:~# /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

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-1464

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.