When clearing out the async mode, do not do so unless the state() is sane.
authorGreg Sabino Mullane <greg@endpoint.com>
Tue, 13 Jan 2015 20:07:49 +0000 (15:07 -0500)
committerGreg Sabino Mullane <greg@endpoint.com>
Tue, 13 Jan 2015 20:07:49 +0000 (15:07 -0500)
Bucardo.pm

index f78d8cf109c9d8e46b463173e4e11ccf4eeadcad..cb82235e02de1014a0cfa26c207e4905bb5f1799 100644 (file)
@@ -5469,9 +5469,13 @@ sub start_kid {
                 my $d = $sync->{db}{$dbname};
 
                 my $dbh = $d->{dbh};
-                ## If we are async, clear it out
+
+                ## If we are async, clear it out - if the connection is still valid!
                 if ($d->{async_active}) {
-                    $dbh->pg_cancel();
+                    my $state = $dbh->state;
+                    if ($state eq '' or $state eq '25P01') {
+                        $dbh->pg_cancel();
+                    }
                     $d->{async_active} = 0;
                 }
                 ## Seperate eval{} for the rollback as we are probably still connected to the transaction.