Changeset 24541
- Timestamp:
- Jun 24, 2009, 2:17:44 PM (17 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 2 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Server.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r24540 r24541 27 27 passwd requirement (not all dbs require a password param) 28 28 - completely rework how mountedvol is populated, drop mount table 29 - infinitely try to get a db handle if the connection fails 29 30 30 31 0.16 -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r24521 r24541 35 35 36 36 # transaction restart/retry regex 37 my $trans_regex = qr/Deadlock Found|Lock wait timeout exceeded|try restarting transaction /i;37 my $trans_regex = qr/Deadlock Found|Lock wait timeout exceeded|try restarting transaction|Can't connect to MySQL server/i; 38 38 39 39 sub new … … 145 145 # processes and the database might have gone away on us. Apache::DBI will 146 146 # take care of getting a valid dbh back. 147 eval { 148 $dbh = DBI->connect_cached( 149 $db_config->dsn, 150 $db_config->dbuser, 151 $db_config->dbpasswd, 152 { 153 RaiseError => 1, 154 PrintError => 0, 155 AutoCommit => 0, 156 }, 157 ); 158 159 $dbh->do( $sql->set_transaction_model ); 160 $log->debug( "connected to database: ", sub { $dbh->data_sources; } ); 161 $dbh->commit; 162 $log->debug("commit"); 163 }; 164 if ( $@ ) { 165 $dbh->rollback if $dbh; 166 $log->debug("rollback"); 167 $log->logdie( "database error: $@" ); 147 TRANS: while (1) { 148 eval { 149 $dbh = DBI->connect_cached( 150 $db_config->dsn, 151 $db_config->dbuser, 152 $db_config->dbpasswd, 153 { 154 RaiseError => 1, 155 PrintError => 0, 156 AutoCommit => 0, 157 }, 158 ); 159 160 $dbh->do( $sql->set_transaction_model ); 161 $log->debug( "connected to database: ", sub { $dbh->data_sources; } ); 162 $dbh->commit; 163 $log->debug("commit"); 164 }; 165 if ($@) { 166 $dbh->rollback if $dbh; 167 $log->debug("rollback") if $dbh; 168 if ($@ =~ qr/Can't connect to MySQL server/) { 169 $log->warn("database error, retrying transaction: $@"); 170 redo TRANS; 171 } 172 $log->logdie( "database error: $@" ); 173 } 174 last; 168 175 } 169 176
Note:
See TracChangeset
for help on using the changeset viewer.
