Cache our makedelta other sync information. Adjust test to test it better.
authorGreg Sabino Mullane <greg@endpoint.com>
Tue, 24 Jun 2014 16:01:19 +0000 (12:01 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Tue, 24 Jun 2014 16:01:19 +0000 (12:01 -0400)
Bucardo.pm
t/10-makedelta.t

index f2e4aa14947716d6c645792409d49d320c35abca..baab9aa40b63e016cd56e8515585d84900091025 100644 (file)
@@ -9585,10 +9585,14 @@ sub push_rows {
                     }, undef, $x->{DBGROUPNAME});
 
                     $self->glog("Signalling all other syncs that this table has changed", LOG_DEBUG);
-                    $SQL = 'SELECT sync FROM bucardo.bucardo_delta_names WHERE sync <> ? AND tablename = ?';
-                    $sth = $dbh->prepare($SQL);
-                    $count = $sth->execute($syncname,$tname);
-                    for my $row (@{ $sth->fetchall_arrayref }) {
+                    ## Cache this
+                    if (! exists $self->{kick_othersyncs}{$syncname}{$tname}) {
+                        $SQL = 'SELECT sync FROM bucardo.bucardo_delta_names WHERE sync <> ? AND tablename = ?';
+                        $sth = $dbh->prepare($SQL);
+                        $count = $sth->execute($syncname,$tname);
+                        $self->{kick_othersyncs}{$syncname}{$tname} = $sth->fetchall_arrayref();
+                    }
+                    for my $row (@{ $self->{kick_othersyncs}{$syncname}{$tname} }) {
                         my $othersync = $row->[0];
                         $self->db_notify($dbh, "kick_sync_$othersync");
                     }
index 779ad07bfbc7f6ec777e94b31d2733a58af1ee37..1e2761f794b5f8321ac73cb4e2846a3bf129f752 100644 (file)
@@ -44,7 +44,7 @@ like $bct->ctl('bucardo add sync deltatest1 relgroup=myrels dbs=A:source,B:sourc
     qr/Added sync "deltatest1"/, 'Create sync "deltatest1"';
 
 # Create a sync for replication from B to C
-like $bct->ctl('bucardo add sync deltatest2 relgroup=myrels dbs=B,C'),
+like $bct->ctl('bucardo add sync deltatest2 relgroup=myrels dbs=B,C autokick=no'),
     qr/Added sync "deltatest2"/, 'Create sync "deltatest2"';
 
 # Listen in on things.
@@ -59,8 +59,7 @@ ok $dbhX->do('LISTEN bucardo_syncdone_deltatest3'),
 ok $bct->restart_bucardo($dbhX), 'Bucardo should start';
 ok $bct->wait_for_notice($dbhX, [qw(
     bucardo_syncdone_deltatest1
-    bucardo_syncdone_deltatest2
-)]), 'The deltatest1 and deltatest2 syncs should finish';
+)]), 'The deltatest1 sync finished';
 
 # Should have no rows.
 $bct->check_for_row([], [qw(A B C)], undef, 'test[124]$');
@@ -70,11 +69,13 @@ ok $dbhA->do(q{INSERT INTO bucardo_test1 (id, data1) VALUES (1, 'foo')}),
     'Insert a row into test1 on A';
 $dbhA->commit;
 
+## Bucardo will fire off deltatest2 itself
 ok $bct->wait_for_notice($dbhX, [qw(
     bucardo_syncdone_deltatest1
     bucardo_syncdone_deltatest2
 )]), 'The deltatest1 and deltatest2 syncs have finished';
 
+
 # The row should be in A and B, as well as C!
 is_deeply $dbhB->selectall_arrayref(
     'SELECT id, data1 FROM bucardo_test1'
@@ -92,6 +93,10 @@ ok $dbhB->do(q{INSERT INTO bucardo_test2 (id, data1) VALUES (2, 'foo')}),
     'Insert a row into test2 on B';
 $dbhB->commit;
 
+## Sync deltatest2 is not automatic, so we need to kick it
+# Kick off the second sync
+$bct->ctl('bucardo kick sync deltatest2 0');
+
 ok $bct->wait_for_notice($dbhX, [qw(
     bucardo_syncdone_deltatest1
     bucardo_syncdone_deltatest2