diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 43631807..7e9022b4 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -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: diff --git a/t/pt-online-schema-change/plugin.t b/t/pt-online-schema-change/plugin.t index 1be15200..fdc12f40 100644 --- a/t/pt-online-schema-change/plugin.t +++ b/t/pt-online-schema-change/plugin.t @@ -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)); diff --git a/t/pt-online-schema-change/samples/plugins/all_hooks.pm b/t/pt-online-schema-change/samples/plugins/all_hooks.pm index f629fc51..0d2a7154 100644 --- a/t/pt-online-schema-change/samples/plugins/all_hooks.pm +++ b/t/pt-online-schema-change/samples/plugins/all_hooks.pm @@ -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;