Home > Uncategorized > bucardo error with sync related to Bucardo.pm DBD::Pg::st

bucardo error with sync related to Bucardo.pm DBD::Pg::st

Today, we were receiving the following error:

[Mon Jul  9 09:04:18 2012]  MCP Warning: Killed (line 1626): DBD::Pg::st execute failed: ERROR:  syntax error at or near ")"
LINE 6:             AND (m.sync = $1 OR m.goat IN ())
                                                   ^ at /usr/share/perl5/vendor_perl/Bucardo.pm line 1626.

It seems that this error is caused by some oddness in the bucardo.herdmap table.

Here’s why…

AND (m.sync = ? OR m.goat IN ($goatlistcodes))

Ahh… so our error reflects that $goatlistcodes means nothing, or rather, it contains nothing.

Where is $gostlistcodes instantiated?

my $goatlistcodes = join ',' => map { $_->{id} } @{$s->{goatlist}};

Where is goatlist instantiated?

$s->{goatlist} = $self->find_goats($s->{source});

What does find_goats() do?

sub find_goats {
    ## Given a herd, return an arrayref of goats
    ## Used in validate_sync

    my ($self,$herd) = @_;
    my $goats = $self->get_goats();
    my $maindbh = $self->{masterdbh};
    $SQL = q{
        SELECT   goat
        FROM     bucardo.herdmap
        WHERE    herd = ?
        ORDER BY priority DESC, goat ASC
    };
    $sth = $maindbh->prepare($SQL);
    $sth->execute($herd);
    my $newgoats = [];
    for (@{$sth->fetchall_arrayref()}) {
        push @$newgoats, $goats->{$_->[0]};
    }
    $maindbh->commit();
    return $newgoats;
} ## end of find_goats

What does get_goats() do?

sub get_goats {
    ## Return a hashref of everything in the goat table
    ## Used by find_goats()

    my $self = shift;

    $SQL = 'SELECT * FROM bucardo.goat';
    $sth = $self->{masterdbh}->prepare($SQL);
    $sth->execute();
    my $info = $sth->fetchall_hashref('id');
    $self->{masterdbh}->commit();
    return $info;
} ## end of get_goats

Luckily, we experienced the problem when we were in QA. The dev was able to drop the entire DB (like a wrecking ball where we could use a hammer, I know), and rebuild it with bucardo_ctl.

My more direct suggestion would be to look at bucardo.goat and bucardo.herdmap on every member, then look into dropping just those tables… although I can not predict what would happen.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: