r16677 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16676‎ | r16677 | r16678 >
Date:19:48, 27 September 2006
Author:brion
Status:old
Tags:
Comment:
* Try to reconnect after transitory database errors in dumpTextPass.php
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/dumpTextPass.php
@@ -102,6 +102,10 @@
103103 var $history = MW_EXPORT_FULL;
104104 var $fetchCount = 0;
105105 var $prefetchCount = 0;
 106+
 107+ var $failures = 0;
 108+ var $maxFailures = 200;
 109+ var $failureTimeout = 5; // Seconds to sleep after db failure
106110
107111 function dump() {
108112 # This shouldn't happen if on console... ;)
@@ -236,6 +240,27 @@
237241 return $text;
238242 }
239243 }
 244+ while( true ) {
 245+ try {
 246+ return $this->doGetText( $id );
 247+ } catch (DBQueryError $ex) {
 248+ $this->failures++;
 249+ if( $this->failures > $this->maxFailures ) {
 250+ throw $ex;
 251+ } else {
 252+ $this->progress( "Database failure $this->failures " .
 253+ "of allowed $this->maxFailures! " .
 254+ "Pausing $this->failureTimeout seconds..." );
 255+ sleep( $this->failureTimeout );
 256+ }
 257+ }
 258+ }
 259+ }
 260+
 261+ /**
 262+ * May throw a database error if, say, the server dies during query.
 263+ */
 264+ private function doGetText( $id ) {
240265 $id = intval( $id );
241266 $row = $this->db->selectRow( 'text',
242267 array( 'old_text', 'old_flags' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -234,6 +234,7 @@
235235 * (bug 6092) Introduce magic words {{REVISIONDAY}}, {{REVISIONDAY2}, {{REVISIONMONTH}},
236236 {{REVISIONYEAR}} and {{REVISIONTIMESTAMP}}
237237 * (bug 7425) Preceeding whitespace in [[...]] breaks subpages
 238+* Try to reconnect after transitory database errors in dumpTextPass.php
238239
239240
240241 == Languages updated ==