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:
Kenny Gryp
2014-03-24 19:25:41 +01:00
parent 433e5db1f6
commit dc6f1442c8
3 changed files with 16 additions and 1 deletions

View File

@@ -8120,6 +8120,12 @@ sub main {
return $ms->get_slave_lag($dbh); 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( $replica_lag = new ReplicaLagWaiter(
slaves => $slave_lag_cxns, slaves => $slave_lag_cxns,
max_lag => $o->get('max-lag'), max_lag => $o->get('max-lag'),
@@ -11345,6 +11351,7 @@ These hooks, in this order, are called if defined:
after_drop_old_table after_drop_old_table
before_drop_triggers before_drop_triggers
before_exit before_exit
override_slavelag_check
Each hook is passed different arguments. To see which arguments are passed 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: to a hook, search for the hook's name in the tool's source code, like:

View File

@@ -56,6 +56,7 @@ my @called = $output =~ m/^PLUGIN \S+$/gm;
is_deeply( is_deeply(
\@called, \@called,
[ [
'PLUGIN override_slavelag_check',
'PLUGIN init', 'PLUGIN init',
'PLUGIN before_create_new_table', 'PLUGIN before_create_new_table',
'PLUGIN after_create_new_table', 'PLUGIN after_create_new_table',
@@ -70,7 +71,7 @@ is_deeply(
'PLUGIN before_drop_old_table', 'PLUGIN before_drop_old_table',
'PLUGIN after_drop_old_table', 'PLUGIN after_drop_old_table',
'PLUGIN before_drop_triggers', 'PLUGIN before_drop_triggers',
'PLUGIN before_exit' 'PLUGIN before_exit',
], ],
"Called all plugins on basic run" "Called all plugins on basic run"
) or diag(Dumper(\@called)); ) or diag(Dumper(\@called));

View File

@@ -96,4 +96,11 @@ sub before_exit {
print "PLUGIN before_exit\n"; print "PLUGIN before_exit\n";
} }
sub override_slavelag_check {
my ($self, %args) = @_;
print "PLUGIN override_slavelag_check\n";
return sub { return 0; };
}
1; 1;