pt-archiver custom module won't work even with documented example

Bug #1111845 reported by Mike Siekkinen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Confirmed
Undecided
Unassigned

Bug Description

I was trying to use the custom modules for pt-archiver documented at http://www.percona.com/doc/percona-toolkit/2.1/pt-archiver.html.

Using an exact copy/paste of the example module

====Begin paste===

package My::Module;

sub new {
   my ( $class, %args ) = @_;
   return bless(\%args, $class);
}

sub before_begin {
   my ( $self, %args ) = @_;
   # Save column names for later
   $self->{cols} = $args{cols};
}

sub is_archivable {
   my ( $self, %args ) = @_;
   # Do some advanced logic with $args{row}
   return 1;
}

sub before_delete {} # Take no action
sub before_insert {} # Take no action
sub custom_sth {} # Take no action
sub after_finish {} # Take no action

1;

====End paste===

I attempt to run with:

pt-archiver --source A=utf8,h=localhost,S=/var/lib/mysql/mysql.sock,u=pt-archiver,p=pt-archiver-password,D=testdb,t=testtable,m=My::Module --no-delete --file /tmp/archive.out --where='id between 1 and 10'

And am greeted with:

Can't call method "before_begin" without a package or object reference at /usr/bin/pt-archiver line 5657.

I have a My/Module.pm in Perls @INC paths so it is definitely able to find the file.

tags: added: docs pt-archiver
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Yes, the docs might be inaccurate. There are tests for plugins, but they use single namespaces instead of multiple like My::Plugin. So perhaps multiple don't actually work. What does work, and is a workaround for the moment, is using a single namespace for the package like "package foo" and put that in foo.pm, then m=foo. If @INC has whatever dir foo.pm is in, that should work.

tags: added: plugin
Changed in percona-toolkit:
status: New → Triaged
Revision history for this message
Mike Siekkinen (9-mikes) wrote :

Thanks for the suggestion but I'm still left with the same error:

Can't call method "before_begin" without a package or object reference at /usr/bin/pt-archiver line 5657.

It looks like I was specific before, but to be clear I am running pt-archiver 2.1.7

Revision history for this message
Mike Siekkinen (9-mikes) wrote :

Also in case this makes a difference,

This is perl, v5.8.8 built for x86_64-linux-thread-multi

Brian Fraser (fraserbn)
Changed in percona-toolkit:
milestone: none → 2.2.2
assignee: nobody → Brian Fraser (fraserbn)
Revision history for this message
Brian Fraser (fraserbn) wrote :

I cannot reproduce this, even with olders versions of the toolkit. Mike, could you try running this:

$ perl -le 'use My::Module; print $INC{q{My/Module.pm}}'

And pasting the output here? Additionally/alternatively, could you paste the output with running the tool with PTDEBUG=1?

Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: Triaged → Incomplete
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Changed back to Confirmed, removed from 2.2.2. We should ensure that examples work exactly as documented. Brian: what did you try?

Changed in percona-toolkit:
status: Incomplete → Confirmed
milestone: 2.2.2 → none
assignee: Brian Fraser (fraserbn) → nobody
Revision history for this message
Ashok Koyi (thekalinga) wrote :

Any idea is this an issue/needs to be fixed?

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-1070

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.