Never treat persistent stat cache as "latest" in FileBackend
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 25 Jan 2015 09:19:24 +0000 (01:19 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 10 Feb 2015 23:30:55 +0000 (23:30 +0000)
bug: T89184
Change-Id: I035c0f85a641efa0e4e3209b2bcf9847c08ab0d2

includes/filebackend/FileBackend.php
includes/filebackend/FileBackendStore.php

index 9504112..b87e26d 100644 (file)
@@ -1204,7 +1204,9 @@ abstract class FileBackend {
 
        /**
         * Preload file stat information (concurrently if possible) into in-process cache.
+        *
         * This should be used when stat calls will be made on a known list of a many files.
+        * This does not make use of the persistent file stat cache.
         *
         * @see FileBackend::getFileStat()
         *
index a3b0009..de189ec 100644 (file)
@@ -627,7 +627,7 @@ abstract class FileBackendStore extends FileBackend {
                }
                $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
                $latest = !empty( $params['latest'] ); // use latest data?
-               if ( !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
+               if ( !$latest && !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
                        $this->primeFileCache( array( $path ) ); // check persistent cache
                }
                if ( $this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
@@ -1745,17 +1745,18 @@ abstract class FileBackendStore extends FileBackend {
                // Get all cache entries for these container cache keys...
                $values = $this->memCache->getMulti( array_keys( $pathNames ) );
                foreach ( $values as $cacheKey => $val ) {
+                       $path = $pathNames[$cacheKey];
                        if ( is_array( $val ) ) {
-                               $path = $pathNames[$cacheKey];
+                               $val['latest'] = false; // never completely trust cache
                                $this->cheapCache->set( $path, 'stat', $val );
                                if ( isset( $val['sha1'] ) ) { // some backends store SHA-1 as metadata
                                        $this->cheapCache->set( $path, 'sha1',
-                                               array( 'hash' => $val['sha1'], 'latest' => $val['latest'] ) );
+                                               array( 'hash' => $val['sha1'], 'latest' => false ) );
                                }
                                if ( isset( $val['xattr'] ) ) { // some backends store headers/metadata
                                        $val['xattr'] = self::normalizeXAttributes( $val['xattr'] );
                                        $this->cheapCache->set( $path, 'xattr',
-                                               array( 'map' => $val['xattr'], 'latest' => $val['latest'] ) );
+                                               array( 'map' => $val['xattr'], 'latest' => false ) );
                                }
                        }
                }