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.
## 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;
}
}