Index: trunk/phase3/includes/db/LoadBalancer.php |
— | — | @@ -242,7 +242,8 @@ |
243 | 243 | if ( $i === false && count( $currentLoads ) != 0 ) { |
244 | 244 | # All slaves lagged. Switch to read-only mode |
245 | 245 | wfDebugLog( 'replication', "All slaves lagged. Switch to read-only mode\n" ); |
246 | | - $wgReadOnly = wfMessage( 'readonly_lag' )->useDatabase( false )->plain(); |
| 246 | + $wgReadOnly = 'The database has been automatically locked ' . |
| 247 | + 'while the slave database servers catch up to the master'; |
247 | 248 | $i = $this->pickRandom( $currentLoads ); |
248 | 249 | $laggedSlaveMode = true; |
249 | 250 | } |
— | — | @@ -679,7 +680,14 @@ |
680 | 681 | |
681 | 682 | # Create object |
682 | 683 | wfDebug( "Connecting to $host $dbname...\n" ); |
683 | | - $db = DatabaseBase::factory( $server['type'], $server ); |
| 684 | + try { |
| 685 | + $db = DatabaseBase::factory( $server['type'], $server ); |
| 686 | + } catch ( DBConnectionError $e ) { |
| 687 | + // FIXME: This is probably the ugliest thing I have ever done to |
| 688 | + // PHP. I'm half-expecting it to segfault, just out of disgust. -- TS |
| 689 | + $db = $e->db; |
| 690 | + } |
| 691 | + |
684 | 692 | if ( $db->isOpen() ) { |
685 | 693 | wfDebug( "Connected to $host $dbname.\n" ); |
686 | 694 | } else { |
— | — | @@ -929,7 +937,7 @@ |
930 | 938 | /** |
931 | 939 | * Get the hostname and lag time of the most-lagged slave. |
932 | 940 | * This is useful for maintenance scripts that need to throttle their updates. |
933 | | - * May attempt to open connections to slaves on the default DB. If there is |
| 941 | + * May attempt to open connections to slaves on the default DB. If there is |
934 | 942 | * no lag, the maximum lag will be reported as -1. |
935 | 943 | * |
936 | 944 | * @param $wiki string Wiki ID, or false for the default database |
— | — | @@ -981,19 +989,19 @@ |
982 | 990 | $this->mLagTimes = array( 0 => 0 ); |
983 | 991 | } else { |
984 | 992 | # Send the request to the load monitor |
985 | | - $this->mLagTimes = $this->getLoadMonitor()->getLagTimes( |
| 993 | + $this->mLagTimes = $this->getLoadMonitor()->getLagTimes( |
986 | 994 | array_keys( $this->mServers ), $wiki ); |
987 | 995 | } |
988 | 996 | return $this->mLagTimes; |
989 | 997 | } |
990 | 998 | |
991 | 999 | /** |
992 | | - * Get the lag in seconds for a given connection, or zero if this load |
993 | | - * balancer does not have replication enabled. |
| 1000 | + * Get the lag in seconds for a given connection, or zero if this load |
| 1001 | + * balancer does not have replication enabled. |
994 | 1002 | * |
995 | | - * This should be used in preference to Database::getLag() in cases where |
996 | | - * replication may not be in use, since there is no way to determine if |
997 | | - * replication is in use at the connection level without running |
| 1003 | + * This should be used in preference to Database::getLag() in cases where |
| 1004 | + * replication may not be in use, since there is no way to determine if |
| 1005 | + * replication is in use at the connection level without running |
998 | 1006 | * potentially restricted queries such as SHOW SLAVE STATUS. Using this |
999 | 1007 | * function instead of Database::getLag() avoids a fatal error in this |
1000 | 1008 | * case on many installations. |