* Try to reconnect after transitory database errors in dumpTextPass.php
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 27 Sep 2006 19:48:50 +0000 (19:48 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 27 Sep 2006 19:48:50 +0000 (19:48 +0000)
RELEASE-NOTES
maintenance/dumpTextPass.php

index 3243d41..553a683 100644 (file)
@@ -234,6 +234,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 6092) Introduce magic words {{REVISIONDAY}}, {{REVISIONDAY2}, {{REVISIONMONTH}},
   {{REVISIONYEAR}} and {{REVISIONTIMESTAMP}} 
 * (bug 7425) Preceeding whitespace in [[...]] breaks subpages
+* Try to reconnect after transitory database errors in dumpTextPass.php
 
 
 == Languages updated ==
index 78367c0..fb668bd 100644 (file)
@@ -102,6 +102,10 @@ class TextPassDumper extends BackupDumper {
        var $history = MW_EXPORT_FULL;
        var $fetchCount = 0;
        var $prefetchCount = 0;
+       
+       var $failures = 0;
+       var $maxFailures = 200;
+       var $failureTimeout = 5; // Seconds to sleep after db failure
 
        function dump() {
                # This shouldn't happen if on console... ;)
@@ -236,6 +240,27 @@ class TextPassDumper extends BackupDumper {
                                return $text;
                        }
                }
+               while( true ) {
+                       try {
+                               return $this->doGetText( $id );
+                       } catch (DBQueryError $ex) {
+                               $this->failures++;
+                               if( $this->failures > $this->maxFailures ) {
+                                       throw $ex;
+                               } else {
+                                       $this->progress( "Database failure $this->failures " .
+                                               "of allowed $this->maxFailures! " .
+                                               "Pausing $this->failureTimeout seconds..." );
+                                       sleep( $this->failureTimeout );
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * May throw a database error if, say, the server dies during query.
+        */
+       private function doGetText( $id ) {
                $id = intval( $id );
                $row = $this->db->selectRow( 'text',
                        array( 'old_text', 'old_flags' ),