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

Bug #1111845 reported by Mike Siekkinen on 2013-01-31
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to

Bug Description

I was trying to use the custom modules for pt-archiver documented at

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


====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/ in Perls @INC paths so it is definitely able to find the file.

tags: added: docs pt-archiver
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, then m=foo. If @INC has whatever dir is in, that should work.

tags: added: plugin
Changed in percona-toolkit:
status: New → Triaged
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

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) on 2013-04-02
Changed in percona-toolkit:
milestone: none → 2.2.2
assignee: nobody → Brian Fraser (fraserbn)
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/}}'

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

Brian Fraser (fraserbn) on 2013-04-16
Changed in percona-toolkit:
status: Triaged → Incomplete
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
Kalinga (thekalinga) wrote :

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

Percona now uses JIRA for bug reports so this bug report is migrated to:

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

Other bug subscribers