From 3f76e12ffb053558c9f7497a86bd74300df4f53f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 27 Sep 2006 19:48:50 +0000 Subject: [PATCH] * Try to reconnect after transitory database errors in dumpTextPass.php --- RELEASE-NOTES | 1 + maintenance/dumpTextPass.php | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3243d41345..553a683a7e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index 78367c0b10..fb668bd4c8 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -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' ), -- 2.20.1