Index: trunk/Nebulous-Server/Changes
===================================================================
--- trunk/Nebulous-Server/Changes	(revision 24540)
+++ trunk/Nebulous-Server/Changes	(revision 24541)
@@ -27,4 +27,5 @@
       passwd requirement (not all dbs require a password param)
     - completely rework how mountedvol is populated, drop mount table
+    - infinitely try to get a db handle if the connection fails
       
 0.16
Index: trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 24540)
+++ trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 24541)
@@ -35,5 +35,5 @@
 
 # transaction restart/retry regex
-my $trans_regex = qr/Deadlock Found|Lock wait timeout exceeded|try restarting transaction/i;
+my $trans_regex = qr/Deadlock Found|Lock wait timeout exceeded|try restarting transaction|Can't connect to MySQL server/i;
 
 sub new
@@ -145,25 +145,32 @@
     # processes and the database might have gone away on us.  Apache::DBI will
     # take care of getting a valid dbh back.
-    eval {
-        $dbh = DBI->connect_cached(
-            $db_config->dsn,
-            $db_config->dbuser,
-            $db_config->dbpasswd,
-            {
-                RaiseError => 1,
-                PrintError => 0,
-                AutoCommit => 0,
-            },
-        );
-
-        $dbh->do( $sql->set_transaction_model );
-        $log->debug( "connected to database: ", sub { $dbh->data_sources; } );
-        $dbh->commit;
-        $log->debug("commit");
-    };
-    if ( $@ ) {
-        $dbh->rollback if $dbh;
-        $log->debug("rollback");
-        $log->logdie( "database error: $@" );
+    TRANS: while (1) {
+        eval {
+            $dbh = DBI->connect_cached(
+                $db_config->dsn,
+                $db_config->dbuser,
+                $db_config->dbpasswd,
+                {
+                    RaiseError => 1,
+                    PrintError => 0,
+                    AutoCommit => 0,
+                },
+            );
+
+            $dbh->do( $sql->set_transaction_model );
+            $log->debug( "connected to database: ", sub { $dbh->data_sources; } );
+            $dbh->commit;
+            $log->debug("commit");
+        };
+        if ($@) {
+            $dbh->rollback if $dbh;
+            $log->debug("rollback") if $dbh;
+            if ($@ =~ qr/Can't connect to MySQL server/) {
+                $log->warn("database error, retrying transaction: $@");
+                redo TRANS;
+            }
+            $log->logdie( "database error: $@" );
+        }
+        last;
     }
 
