From: David E. Wheeler Date: Wed, 24 Jul 2013 17:45:50 +0000 (+0200) Subject: Listen for autokicks on sources for the sync, not all sources. X-Git-Tag: 4.99.8~32 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=a5c43c002a2f7319023eed13702aa1f3666198f7;p=bucardo.git Listen for autokicks on sources for the sync, not all sources. I had a database in two dbgroups (and syncs), once as a target and once as a source. On startup, `validate_sync()` was processing the sync where it was a target, first, and that was the role saved for it in `$self->{sdb}`. Then, when `validate_sync()` iterated over `$self->{sdb}`, it thought it was a role, and so did not have the MCP listen for kicks. Not only that, but sources from other, previously-validated syncs were unnecessarily listening for kicks! So change the code to iterate over the list of DBs for the current call to `validate_sync()`, not all dbs for all syncs, when figuring out whereq to listen to for kicks. Note that the use of the same db object in multiple db groups and syncs *may* cause issues in other places. It would be smart to audit all code that checks the value in `{role}` for each hash in `$self->{sdb}` and figure out if it is appropriate. Since the same db can have different roles in differnt syncs, it might make sense to record all of its roles and to check all of them, rather than just rely on the first role found. --- diff --git a/Bucardo.pm b/Bucardo.pm index ee2079657..839dc03f9 100644 --- a/Bucardo.pm +++ b/Bucardo.pm @@ -6340,12 +6340,13 @@ sub validate_sync { ## If autokick, listen for a triggerkick on all source databases if ($s->{autokick}) { my $l = "kick_sync_$syncname"; - for my $dbname (sort keys %{ $self->{sdb} }) { - $x = $self->{sdb}{$dbname}; + for my $dbname (sort keys %{ $s->{db} }) { + $x = $s->{db}{$dbname}; + $self->glog("Listen for $l on $dbname ($x->{role})"); next if $x->{role} ne 'source'; - - $self->db_listen($x->{dbh}, $l, $dbname, 0); - $x->{dbh}->commit(); + my $dbh = $self->{sdb}{$dbname}{dbh}; + $self->db_listen($dbh, $l, $dbname, 0); + $dbh->commit; } }