[Jifty-commit] jifty-dbi branch, master, updated. 0.71-3-gcadc0af

Jifty commits jifty-commit at lists.jifty.org
Mon Oct 17 12:37:01 EDT 2011


The branch, master has been updated
       via  cadc0af7d62005691c7575767ac47f8b9f577af3 (commit)
       via  361fb90627b256cc9878d7c726056ff9cf6b3ac0 (commit)
      from  ccd6ebafb40b6c1ad5a1cd2513b2d06890b9274b (commit)

Summary of changes:
 lib/Jifty/DBI/Handle.pm |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 361fb90627b256cc9878d7c726056ff9cf6b3ac0
Author: Luke Closs <luke at 5thplane.com>
Date:   Thu Oct 13 13:23:08 2011 -0700

    Handle DBH connection errors, retry the query
    
    $@ is only set if RaiseError is set on the DBH, which may not
    always be the case.
    
    We must create a new $sth after we've re-connected, as the $sth contains
    a reference to the (now bad) $dbh.

diff --git a/lib/Jifty/DBI/Handle.pm b/lib/Jifty/DBI/Handle.pm
index 85c1d79..6c2ab3a 100755
--- a/lib/Jifty/DBI/Handle.pm
+++ b/lib/Jifty/DBI/Handle.pm
@@ -521,6 +521,7 @@ Execute the SQL string specified in QUERY_STRING
 
 =cut
 
+our $retry_simple_query = 1;
 sub simple_query {
     my $self         = shift;
     my $query_string = shift;
@@ -571,10 +572,15 @@ sub simple_query {
         eval { $executed = $sth->execute(@bind_values) };
 
         # try to ping and reconnect, if the DB connection failed
-        if ($@ and !$self->dbh->ping) {
+        if (($@ or not $executed) and !$self->dbh->ping) {
             $self->dbh(undef); # don't try pinging again, just connect
             $self->connect; 
-            eval { $executed = $sth->execute(@bind_values) };
+
+            # Need to call ourselves, to create a new sth from the new dbh
+            if ($retry_simple_query) {
+                local $retry_simple_query = 0;
+                return $self->simple_query($query_string, @_);
+            }
         }
     }
     if ( $self->log_sql_statements ) {

commit cadc0af7d62005691c7575767ac47f8b9f577af3
Merge: ccd6eba 361fb90
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Oct 17 12:35:20 2011 -0400

    Merge remote-tracking branch 'remotes/lukec/master'


-----------------------------------------------------------------------


More information about the Jifty-commit mailing list