[Bucardo-general] Patch against for the syncrun multiple entries again (against 4.99.10 this time)

Michelle Sullivan michelle at shellsshots.biz
Sat Nov 16 12:38:17 UTC 2013


--- Bucardo-4.99.10/Bucardo.pm  2013-11-15 23:05:50.000000000 +0000
+++ Bucardo-4.99.10-syncrun-patch/Bucardo.pm    2013-11-16
12:31:48.000000000 +0000
@@ -1910,6 +1910,16 @@
             ## At this point, the PID file does not exist or the kid is
not responding
             if ($resurrect) {
                 ## XXX Try harder to kill it?
+                ## First clear out any old entries in the syncrun table
+                $sth = $sth{ctl_syncrun_end_now};
+                $count = $sth->execute("Old entry died (CTL $$)",
$syncname);
+                if (1 == $count) {
+                    $info = $sth->fetchall_arrayref()->[0][0];
+                    $self->glog("Old syncrun entry removed during
resurrection, start time was $info", LOG_NORMAL);
+                }
+                else {
+                    $sth->finish();
+                }
                 $self->glog("Resurrecting kid $syncname, resurrect was
$resurrect", LOG_DEBUG);
                 $self->{kidpid} = $self->create_newkid($sync);
 
@@ -4912,8 +4922,10 @@
         ## Roll everyone back
         for my $dbname (@dbs_dbi) {
             my $dbh = $sync->{db}{$dbname}{dbh};
-            $dbh->pg_cancel if $dbh->{pg_async_status} > 0;
-            $dbh->rollback;
+            ## Wrapped in an eval as a failure to serialise can cause
an abort() and the KID will die.
+            eval { $dbh->pg_cancel if $dbh->{pg_async_status} > 0; };
+            ## Seperate eval{} for the rollback as we are probably
still connected to the transaction.
+            eval { $dbh->rollback; };
         }
 
         # End the syncrun.

-- 
Michelle Sullivan
http://www.mhix.org/



More information about the Bucardo-general mailing list