Merge "Made TransactionProfiler handle nested transactions to the same server/DB"
[lhc/web/wiklou.git] / includes / filebackend / FileBackendStore.php
index 5776013..ce4dedd 100644 (file)
@@ -1102,19 +1102,35 @@ abstract class FileBackendStore extends FileBackend {
                        $paths = array_merge( $paths, $op->storagePathsRead() );
                        $paths = array_merge( $paths, $op->storagePathsChanged() );
                }
+
+               // Enlarge the cache to fit the stat entries of these files
+               $this->cheapCache->resize( max( 2 * count( $paths ), self::CACHE_CHEAP_SIZE ) );
+
                // Load from the persistent container caches
                $this->primeContainerCache( $paths );
                // Get the latest stat info for all the files (having locked them)
-               $this->preloadFileStat( array( 'srcs' => $paths, 'latest' => true ) );
+               $ok = $this->preloadFileStat( array( 'srcs' => $paths, 'latest' => true ) );
 
-               // Actually attempt the operation batch...
-               $opts = $this->setConcurrencyFlags( $opts );
-               $subStatus = FileOpBatch::attempt( $performOps, $opts, $this->fileJournal );
+               if ( $ok ) {
+                       // Actually attempt the operation batch...
+                       $opts = $this->setConcurrencyFlags( $opts );
+                       $subStatus = FileOpBatch::attempt( $performOps, $opts, $this->fileJournal );
+               } else {
+                       // If we could not even stat some files, then bail out...
+                       $subStatus = Status::newFatal( 'backend-fail-internal', $this->name );
+                       foreach ( $ops as $i => $op ) { // mark each op as failed
+                               $subStatus->success[$i] = false;
+                               ++$subStatus->failCount;
+                       }
+               }
 
                // Merge errors into status fields
                $status->merge( $subStatus );
                $status->success = $subStatus->success; // not done in merge()
 
+               // Shrink the stat cache back to normal size
+               $this->cheapCache->resize( self::CACHE_CHEAP_SIZE );
+
                return $status;
        }
 
@@ -1282,11 +1298,12 @@ abstract class FileBackendStore extends FileBackend {
 
        final public function preloadFileStat( array $params ) {
                $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+               $success = true; // no network errors
 
                $params['concurrency'] = ( $this->parallelize !== 'off' ) ? $this->concurrency : 1;
                $stats = $this->doGetFileStatMulti( $params );
                if ( $stats === null ) {
-                       return; // not supported
+                       return true; // not supported
                }
 
                $latest = !empty( $params['latest'] ); // use latest data?
@@ -1318,9 +1335,12 @@ abstract class FileBackendStore extends FileBackend {
                                        array( 'hash' => false, 'latest' => $latest ) );
                                wfDebug( __METHOD__ . ": File $path does not exist.\n" );
                        } else { // an error occurred
+                               $success = false;
                                wfDebug( __METHOD__ . ": Could not stat file $path.\n" );
                        }
                }
+
+               return $success;
        }
 
        /**