r106408 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106407‎ | r106408 | r106409 >
Date:03:38, 16 December 2011
Author:aaron
Status:ok
Tags:
Comment:
Use FileOperation log to record operation failures...might be useful for recovery
Modified paths:
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php (modified) (history)

Diff [purge]

Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php
@@ -35,7 +35,7 @@
3636 * 'backends' : Array of backend config and multi-backend settings.
3737 * Each value is the config used in the constructor of a
3838 * FileBackend class, but with these additional settings:
39 - * 'class' : The name of the backend class
 39+ * 'class' : The name of the backend class
4040 * 'isMultiMaster': This must be set for one non-persistent backend.
4141 * @param $config Array
4242 */
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php
@@ -184,6 +184,7 @@
185185 $status = $this->doAttempt();
186186 if ( !$status->isOK() ) {
187187 $this->failed = true;
 188+ $this->logFailure( 'attempt' );
188189 }
189190 return $status;
190191 }
@@ -202,6 +203,9 @@
203204 $status = Status::newGood(); // nothing to revert
204205 } else {
205206 $status = $this->doRevert();
 207+ if ( !$status->isOK() ) {
 208+ $this->logFailure( 'revert' );
 209+ }
206210 }
207211 return $status;
208212 }
@@ -465,6 +469,33 @@
466470 return $this->backend->fileExists( array( 'src' => $source ) );
467471 }
468472 }
 473+
 474+ /**
 475+ * Log a file operation failure and preserve any temp files
 476+ *
 477+ * @param $fileOp FileOp
 478+ * @return void
 479+ */
 480+ final protected function logFailure( $action ) {
 481+ $params = $this->params;
 482+ $params['failedAction'] = $action;
 483+ // Preserve backup files just in case (for recovery)
 484+ if ( $this->tmpSourceFile ) {
 485+ $this->tmpSourceFile->preserve(); // don't purge
 486+ $params['srcBackupPath'] = $this->tmpSourceFile->getPath();
 487+ }
 488+ if ( $this->tmpDestFile ) {
 489+ $this->tmpDestFile->preserve(); // don't purge
 490+ $params['dstBackupPath'] = $this->tmpDestFile->getPath();
 491+ }
 492+ try {
 493+ wfDebugLog( 'FileOperation',
 494+ get_class( $this ) . ' failed:' . serialize( $params ) );
 495+ } catch ( Exception $e ) {
 496+ // bad config? debug log error?
 497+ }
 498+ }
 499+
469500 }
470501
471502 /**
Index: branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php
@@ -700,7 +700,7 @@
701701 * @return string
702702 */
703703 protected function getMissKey( $lockDb ) {
704 - return "lockmanager:querymisses:$lockDb";
 704+ return 'lockmanager:querymisses:' . str_replace( ' ', '_', $lockDb );
705705 }
706706
707707 /**

Status & tagging log