mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-15 16:00:23 +00:00
pt-online-schema-chnage: Added plugin feature 'override_slavelag_check' which allows modules to create their own ReplicaLagWaiter callback.
I fixed the current tests.
This commit is contained in:
@@ -8120,6 +8120,12 @@ sub main {
|
||||
return $ms->get_slave_lag($dbh);
|
||||
};
|
||||
|
||||
# The plugin is able to override the slavelag check so tools like pt-heartbeat
|
||||
# or other replicators (Tungsten...) can be used to measure replication lag
|
||||
if ( $plugin && $plugin->can('override_slavelag_check') ) {
|
||||
$get_lag = $plugin->override_slavelag_check();
|
||||
}
|
||||
|
||||
$replica_lag = new ReplicaLagWaiter(
|
||||
slaves => $slave_lag_cxns,
|
||||
max_lag => $o->get('max-lag'),
|
||||
@@ -11345,6 +11351,7 @@ These hooks, in this order, are called if defined:
|
||||
after_drop_old_table
|
||||
before_drop_triggers
|
||||
before_exit
|
||||
override_slavelag_check
|
||||
|
||||
Each hook is passed different arguments. To see which arguments are passed
|
||||
to a hook, search for the hook's name in the tool's source code, like:
|
||||
|
@@ -56,6 +56,7 @@ my @called = $output =~ m/^PLUGIN \S+$/gm;
|
||||
is_deeply(
|
||||
\@called,
|
||||
[
|
||||
'PLUGIN override_slavelag_check',
|
||||
'PLUGIN init',
|
||||
'PLUGIN before_create_new_table',
|
||||
'PLUGIN after_create_new_table',
|
||||
@@ -70,7 +71,7 @@ is_deeply(
|
||||
'PLUGIN before_drop_old_table',
|
||||
'PLUGIN after_drop_old_table',
|
||||
'PLUGIN before_drop_triggers',
|
||||
'PLUGIN before_exit'
|
||||
'PLUGIN before_exit',
|
||||
],
|
||||
"Called all plugins on basic run"
|
||||
) or diag(Dumper(\@called));
|
||||
|
@@ -96,4 +96,11 @@ sub before_exit {
|
||||
print "PLUGIN before_exit\n";
|
||||
}
|
||||
|
||||
sub override_slavelag_check {
|
||||
my ($self, %args) = @_;
|
||||
print "PLUGIN override_slavelag_check\n";
|
||||
|
||||
return sub { return 0; };
|
||||
}
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user