X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilebackend%2FFileOpBatch.php;h=e90fcb7820323680d34c96c1e7e8df29f2d4e646;hb=02df705dd8b152d7310d08ed8f9bdd95e1948d64;hp=32b65baba17460eee83f5cd791b6ec0bd095b505;hpb=e3a09619157b8245c58eb592e58cc62f6a3b1744;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filebackend/FileOpBatch.php b/includes/filebackend/FileOpBatch.php index 32b65baba1..e90fcb7820 100644 --- a/includes/filebackend/FileOpBatch.php +++ b/includes/filebackend/FileOpBatch.php @@ -55,13 +55,12 @@ class FileOpBatch { * @return Status */ public static function attempt( array $performOps, array $opts, FileJournal $journal ) { - wfProfileIn( __METHOD__ ); + $section = new ProfileSection( __METHOD__ ); $status = Status::newGood(); $n = count( $performOps ); if ( $n > self::MAX_BATCH_SIZE ) { $status->fatal( 'backend-fail-batchsize', $n, self::MAX_BATCH_SIZE ); - wfProfileOut( __METHOD__ ); return $status; } @@ -108,8 +107,6 @@ class FileOpBatch { $status->success[$index] = false; ++$status->failCount; if ( !$ignoreErrors ) { - wfProfileOut( __METHOD__ ); - return $status; // abort } } @@ -123,8 +120,6 @@ class FileOpBatch { if ( count( $entries ) ) { $subStatus = $journal->logChangeBatch( $entries, $batchId ); if ( !$subStatus->isOK() ) { - wfProfileOut( __METHOD__ ); - return $subStatus; // abort } } @@ -136,8 +131,6 @@ class FileOpBatch { // Attempt each operation (in parallel if allowed and possible)... self::runParallelBatches( $pPerformOps, $status ); - wfProfileOut( __METHOD__ ); - return $status; } @@ -149,9 +142,8 @@ class FileOpBatch { * within any given sub-batch do not depend on each other. * This will abort remaining ops on failure. * - * @param array $pPerformOps + * @param array $pPerformOps Batches of file ops (batches use original indexes) * @param Status $status - * @return bool Success */ protected static function runParallelBatches( array $pPerformOps, Status $status ) { $aborted = false; // set to true on unexpected errors @@ -172,12 +164,8 @@ class FileOpBatch { // If attemptAsync() returns a Status, it was either due to an error // or the backend does not support async ops and did it synchronously. foreach ( $performOpsBatch as $i => $fileOp ) { - if ( !$fileOp->failed() ) { // failed => already has Status - // If the batch is just one operation, it's faster to avoid - // pipelining as that can involve creating new TCP connections. - $subStatus = ( count( $performOpsBatch ) > 1 ) - ? $fileOp->attemptAsync() - : $fileOp->attempt(); + if ( !isset( $status->success[$i] ) ) { // didn't already fail in precheck() + $subStatus = $fileOp->attemptAsync(); if ( $subStatus->value instanceof FileBackendStoreOpHandle ) { $opHandles[$i] = $subStatus->value; // deferred } else { @@ -189,7 +177,7 @@ class FileOpBatch { $statuses = $statuses + $backend->executeOpHandlesInternal( $opHandles ); // Marshall and merge all the responses (blocking)... foreach ( $performOpsBatch as $i => $fileOp ) { - if ( !$fileOp->failed() ) { // failed => already has Status + if ( !isset( $status->success[$i] ) ) { // didn't already fail in precheck() $subStatus = $statuses[$i]; $status->merge( $subStatus ); if ( $subStatus->isOK() ) { @@ -203,7 +191,5 @@ class FileOpBatch { } } } - - return $status; } }