Pt-table-sync "unitialized value in concatenation" error

I’ve been using pt-table-sync for a number of years to recover from database sync issues in MySQL and more recently MariaDB. It has been working without issue on our current servers for some time. No when I try to use it though, I always get the same error:

[root@host1 ~]# pt-table-sync --execute --databases=my_database --sync-to-source host1
Use of uninitialized value in concatenation (.) or string at /usr/bin/pt-table-sync line 7086.

[root@host1 ~]# pt-table-sync --version
pt-table-sync 3.7.0

I’m guessing this is a result from updating to 3.7.0, though I’m not sure how long we’ve been on that version, so couldn’t say for sure. Is this a bug, or am I doing something wrong here?

Hi @nstretch ,
Have you looked at the source code at line 7086? Perhaps that can give you some insight as to the issue?

Line 7086 is the last line of this function before the return:

sub get_source_dsn {
   my ( $self, $dbh, $dsn, $dsn_parser ) = @_;

   my $vp = VersionParser->new($dbh);
   my $source_host = 'source_host';
   my $source_port = 'source_port';
   if ( $vp lt '8.1' || $vp->flavor() =~ m/maria/ ) {
      $source_host = 'master_host';
      $source_port = 'master_port';
   }

   my $source = $self->get_replica_status($dbh) or return undef;
   my $spec   = "h=$source->{${source_host}},P=$source->{${source_port}}";
   return       $dsn_parser->parse($spec, $dsn);
}

I added some debugging printouts, and it appears the problem is that it’s looking for source_host and source_port in $source, but these don’t exist; instead master_host and master_port are present. But the ($vp lt ‘8.1’ || $vp->flavor() =~ m/maria/) test is returning false.

Looks like that’s because flavor() returns “MariaDB Server”, which doesn’t match because the test is case sensitive. Changing to m/maria/i fixes that. There are several other places throughout the script where the same check for MariaDB is done (maybe it would be better for it just to be checked once and saved?) so I needed to update all of them.

Good diagnosis. Please open a bug report and provide this info at https://jira.percona.com/
CC: @svetasmirnova

I would, but I can’t seem to log in to the Percona Jira, just keep getting redirected back to the login screen. Anyway, hopefully the report here helps.

I filed the bug for you since you were having login issues.
https://perconadev.atlassian.net/browse/PT-2425

1 Like