summaryrefslogtreecommitdiff
path: root/includes/filebackend
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /includes/filebackend
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'includes/filebackend')
-rw-r--r--includes/filebackend/FSFile.php7
-rw-r--r--includes/filebackend/FSFileBackend.php8
-rw-r--r--includes/filebackend/FileBackend.php4
-rw-r--r--includes/filebackend/FileBackendMultiWrite.php6
-rw-r--r--includes/filebackend/FileBackendStore.php87
-rw-r--r--includes/filebackend/FileOpBatch.php1
-rw-r--r--includes/filebackend/SwiftFileBackend.php81
-rw-r--r--includes/filebackend/TempFSFile.php3
-rw-r--r--includes/filebackend/filejournal/FileJournal.php4
-rw-r--r--includes/filebackend/lockmanager/DBLockManager.php4
-rw-r--r--includes/filebackend/lockmanager/LockManager.php10
-rw-r--r--includes/filebackend/lockmanager/LockManagerGroup.php16
-rw-r--r--includes/filebackend/lockmanager/MemcLockManager.php6
-rw-r--r--includes/filebackend/lockmanager/RedisLockManager.php2
14 files changed, 128 insertions, 111 deletions
diff --git a/includes/filebackend/FSFile.php b/includes/filebackend/FSFile.php
index 1659c62a..6ee9b2e0 100644
--- a/includes/filebackend/FSFile.php
+++ b/includes/filebackend/FSFile.php
@@ -104,7 +104,6 @@ class FSFile {
* @return array
*/
public function getProps( $ext = true ) {
- wfProfileIn( __METHOD__ );
wfDebug( __METHOD__ . ": Getting file info for $this->path\n" );
$info = self::placeholderProps();
@@ -146,8 +145,6 @@ class FSFile {
wfDebug( __METHOD__ . ": $this->path NOT FOUND!\n" );
}
- wfProfileOut( __METHOD__ );
-
return $info;
}
@@ -201,10 +198,8 @@ class FSFile {
* @return bool|string False on failure
*/
public function getSha1Base36( $recache = false ) {
- wfProfileIn( __METHOD__ );
if ( $this->sha1Base36 !== null && !$recache ) {
- wfProfileOut( __METHOD__ );
return $this->sha1Base36;
}
@@ -217,8 +212,6 @@ class FSFile {
$this->sha1Base36 = wfBaseConvert( $this->sha1Base36, 16, 36, 31 );
}
- wfProfileOut( __METHOD__ );
-
return $this->sha1Base36;
}
diff --git a/includes/filebackend/FSFileBackend.php b/includes/filebackend/FSFileBackend.php
index b99ffb62..07370ad2 100644
--- a/includes/filebackend/FSFileBackend.php
+++ b/includes/filebackend/FSFileBackend.php
@@ -451,10 +451,13 @@ class FSFileBackend extends FileBackendStore {
// Create the directory and its parents as needed...
$this->trapWarnings();
if ( !wfMkdirParents( $dir ) ) {
+ wfDebugLog( 'FSFileBackend', __METHOD__ . ": cannot create directory $dir" );
$status->fatal( 'directorycreateerror', $params['dir'] ); // fails on races
} elseif ( !is_writable( $dir ) ) {
+ wfDebugLog( 'FSFileBackend', __METHOD__ . ": directory $dir is read-only" );
$status->fatal( 'directoryreadonlyerror', $params['dir'] );
} elseif ( !is_readable( $dir ) ) {
+ wfDebugLog( 'FSFileBackend', __METHOD__ . ": directory $dir is not readable" );
$status->fatal( 'directorynotreadableerror', $params['dir'] );
}
$this->untrapWarnings();
@@ -678,6 +681,11 @@ class FSFileBackend extends FileBackendStore {
return false;
}
+ /**
+ * @param FileBackendStoreOpHandle[] $fileOpHandles
+ *
+ * @return Status[]
+ */
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
$statuses = array();
diff --git a/includes/filebackend/FileBackend.php b/includes/filebackend/FileBackend.php
index 8c0a61a1..b87e26d3 100644
--- a/includes/filebackend/FileBackend.php
+++ b/includes/filebackend/FileBackend.php
@@ -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()
*
@@ -1491,7 +1493,7 @@ abstract class FileBackend {
* @ingroup FileBackend
* @since 1.23
*/
-class FileBackendException extends MWException {
+class FileBackendException extends Exception {
}
/**
diff --git a/includes/filebackend/FileBackendMultiWrite.php b/includes/filebackend/FileBackendMultiWrite.php
index bfffcc0f..f2d13eeb 100644
--- a/includes/filebackend/FileBackendMultiWrite.php
+++ b/includes/filebackend/FileBackendMultiWrite.php
@@ -299,7 +299,7 @@ class FileBackendMultiWrite extends FileBackend {
/**
* Check that a set of files are consistent across all internal backends
- * and re-synchronize those files againt the "multi master" if needed.
+ * and re-synchronize those files against the "multi master" if needed.
*
* @param array $paths List of storage paths
* @return Status
@@ -314,6 +314,8 @@ class FileBackendMultiWrite extends FileBackend {
$mStat = $mBackend->getFileStat( array( 'src' => $mPath, 'latest' => true ) );
if ( $mStat === null || ( $mSha1 !== false && !$mStat ) ) { // sanity
$status->fatal( 'backend-fail-internal', $this->name );
+ wfDebugLog( 'FileOperation', __METHOD__
+ . ': File is not available on the master backend' );
continue; // file is not available on the master backend...
}
// Check of all clone backends agree with the master...
@@ -326,6 +328,8 @@ class FileBackendMultiWrite extends FileBackend {
$cStat = $cBackend->getFileStat( array( 'src' => $cPath, 'latest' => true ) );
if ( $cStat === null || ( $cSha1 !== false && !$cStat ) ) { // sanity
$status->fatal( 'backend-fail-internal', $cBackend->getName() );
+ wfDebugLog( 'FileOperation', __METHOD__
+ . ': File is not available on the clone backend' );
continue; // file is not available on the clone backend...
}
if ( $mSha1 === $cSha1 ) {
diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php
index 495ac3c0..25e87d43 100644
--- a/includes/filebackend/FileBackendStore.php
+++ b/includes/filebackend/FileBackendStore.php
@@ -118,7 +118,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function createInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
if ( strlen( $params['content'] ) > $this->maxFileSizeInternal() ) {
$status = Status::newFatal( 'backend-fail-maxsize',
$params['dst'], $this->maxFileSizeInternal() );
@@ -159,7 +159,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function storeInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
if ( filesize( $params['src'] ) > $this->maxFileSizeInternal() ) {
$status = Status::newFatal( 'backend-fail-maxsize',
$params['dst'], $this->maxFileSizeInternal() );
@@ -201,7 +201,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function copyInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = $this->doCopyInternal( $params );
$this->clearCache( array( $params['dst'] ) );
if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
@@ -233,7 +233,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function deleteInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = $this->doDeleteInternal( $params );
$this->clearCache( array( $params['src'] ) );
$this->deleteFileCache( $params['src'] ); // persistent cache
@@ -267,7 +267,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function moveInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = $this->doMoveInternal( $params );
$this->clearCache( array( $params['src'], $params['dst'] ) );
$this->deleteFileCache( $params['src'] ); // persistent cache
@@ -313,7 +313,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function describeInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
if ( count( $params['headers'] ) ) {
$status = $this->doDescribeInternal( $params );
$this->clearCache( array( $params['src'] ) );
@@ -346,7 +346,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function concatenate( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Try to lock the source files for the scope of this function
@@ -439,7 +439,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doPrepare( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
@@ -474,7 +474,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doSecure( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
@@ -509,7 +509,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doPublish( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
@@ -544,7 +544,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doClean( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Recursive: first delete all empty subdirs recursively
@@ -600,21 +600,21 @@ abstract class FileBackendStore extends FileBackend {
}
final public function fileExists( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$stat = $this->getFileStat( $params );
return ( $stat === null ) ? null : (bool)$stat; // null => failure
}
final public function getFileTimestamp( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$stat = $this->getFileStat( $params );
return $stat ? $stat['mtime'] : false;
}
final public function getFileSize( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$stat = $this->getFileStat( $params );
return $stat ? $stat['size'] : false;
@@ -625,9 +625,9 @@ abstract class FileBackendStore extends FileBackend {
if ( $path === null ) {
return false; // invalid storage path
}
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $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 ) ) {
@@ -644,9 +644,7 @@ abstract class FileBackendStore extends FileBackend {
}
}
}
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$stat = $this->doGetFileStat( $params );
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
if ( is_array( $stat ) ) { // file exists
// Strongly consistent backends can automatically set "latest"
$stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest;
@@ -679,7 +677,7 @@ abstract class FileBackendStore extends FileBackend {
abstract protected function doGetFileStat( array $params );
public function getFileContentsMulti( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$params = $this->setConcurrencyFlags( $params );
$contents = $this->doGetFileContentsMulti( $params );
@@ -708,7 +706,7 @@ abstract class FileBackendStore extends FileBackend {
if ( $path === null ) {
return false; // invalid storage path
}
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$latest = !empty( $params['latest'] ); // use latest data?
if ( $this->cheapCache->has( $path, 'xattr', self::CACHE_TTL ) ) {
$stat = $this->cheapCache->get( $path, 'xattr' );
@@ -718,12 +716,8 @@ abstract class FileBackendStore extends FileBackend {
return $stat['map'];
}
}
- wfProfileIn( __METHOD__ . '-miss' );
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$fields = $this->doGetFileXAttributes( $params );
$fields = is_array( $fields ) ? self::normalizeXAttributes( $fields ) : false;
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
- wfProfileOut( __METHOD__ . '-miss' );
$this->cheapCache->set( $path, 'xattr', array( 'map' => $fields, 'latest' => $latest ) );
return $fields;
@@ -742,7 +736,7 @@ abstract class FileBackendStore extends FileBackend {
if ( $path === null ) {
return false; // invalid storage path
}
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$latest = !empty( $params['latest'] ); // use latest data?
if ( $this->cheapCache->has( $path, 'sha1', self::CACHE_TTL ) ) {
$stat = $this->cheapCache->get( $path, 'sha1' );
@@ -752,9 +746,7 @@ abstract class FileBackendStore extends FileBackend {
return $stat['hash'];
}
}
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$hash = $this->doGetFileSha1Base36( $params );
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
$this->cheapCache->set( $path, 'sha1', array( 'hash' => $hash, 'latest' => $latest ) );
return $hash;
@@ -775,7 +767,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function getFileProps( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$fsFile = $this->getLocalReference( $params );
$props = $fsFile ? $fsFile->getProps() : FSFile::placeholderProps();
@@ -783,7 +775,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function getLocalReferenceMulti( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$params = $this->setConcurrencyFlags( $params );
@@ -826,7 +818,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function getLocalCopyMulti( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$params = $this->setConcurrencyFlags( $params );
$tmpFiles = $this->doGetLocalCopyMulti( $params );
@@ -851,7 +843,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function streamFile( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
$info = $this->getFileStat( $params );
@@ -865,9 +857,7 @@ abstract class FileBackendStore extends FileBackend {
if ( $res == StreamFile::NOT_MODIFIED ) {
// do nothing; client cache is up to date
} elseif ( $res == StreamFile::READY_STREAM ) {
- wfProfileIn( __METHOD__ . '-send-' . $this->name );
$status = $this->doStreamFile( $params );
- wfProfileOut( __METHOD__ . '-send-' . $this->name );
if ( !$status->isOK() ) {
// Per bug 41113, nasty things can happen if bad cache entries get
// stuck in cache. It's also possible that this error can come up
@@ -1071,7 +1061,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doOperationsInternal( array $ops, array $opts ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Fix up custom header name/value pairs...
@@ -1137,7 +1127,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doQuickOperationsInternal( array $ops ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Fix up custom header name/value pairs...
@@ -1198,13 +1188,13 @@ abstract class FileBackendStore extends FileBackend {
* The resulting Status object fields will correspond
* to the order in which the handles where given.
*
- * @param array $fileOpHandles
+ * @param FileBackendStoreOpHandle[] $fileOpHandles
+ *
* @throws FileBackendError
- * @internal param array $handles List of FileBackendStoreOpHandle objects
* @return array Map of Status objects
*/
final public function executeOpHandlesInternal( array $fileOpHandles ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
foreach ( $fileOpHandles as $fileOpHandle ) {
if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) {
@@ -1223,9 +1213,11 @@ abstract class FileBackendStore extends FileBackend {
/**
* @see FileBackendStore::executeOpHandlesInternal()
- * @param array $fileOpHandles
+ *
+ * @param FileBackendStoreOpHandle[] $fileOpHandles
+ *
* @throws FileBackendError
- * @return array List of corresponding Status objects
+ * @return Status[] List of corresponding Status objects
*/
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
if ( count( $fileOpHandles ) ) {
@@ -1300,7 +1292,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function preloadFileStat( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$success = true; // no network errors
$params['concurrency'] = ( $this->parallelize !== 'off' ) ? $this->concurrency : 1;
@@ -1372,7 +1364,7 @@ abstract class FileBackendStore extends FileBackend {
/**
* Check if a container name is valid.
- * This checks for for length and illegal characters.
+ * This checks for length and illegal characters.
*
* @param string $container
* @return bool
@@ -1623,7 +1615,7 @@ abstract class FileBackendStore extends FileBackend {
* @param array $items
*/
final protected function primeContainerCache( array $items ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$paths = array(); // list of storage paths
$contNames = array(); // (cache key => resolved container name)
@@ -1733,7 +1725,7 @@ abstract class FileBackendStore extends FileBackend {
* @param array $items List of storage paths
*/
final protected function primeFileCache( array $items ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$paths = array(); // list of storage paths
$pathNames = array(); // (cache key => storage path)
@@ -1755,17 +1747,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 ) );
}
}
}
diff --git a/includes/filebackend/FileOpBatch.php b/includes/filebackend/FileOpBatch.php
index b0d83e01..faa13144 100644
--- a/includes/filebackend/FileOpBatch.php
+++ b/includes/filebackend/FileOpBatch.php
@@ -55,7 +55,6 @@ class FileOpBatch {
* @return Status
*/
public static function attempt( array $performOps, array $opts, FileJournal $journal ) {
- $section = new ProfileSection( __METHOD__ );
$status = Status::newGood();
$n = count( $performOps );
diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php
index f40ec46e..5f406c9b 100644
--- a/includes/filebackend/SwiftFileBackend.php
+++ b/includes/filebackend/SwiftFileBackend.php
@@ -112,7 +112,7 @@ class SwiftFileBackend extends FileBackendStore {
// Optional settings
$this->authTTL = isset( $config['swiftAuthTTL'] )
? $config['swiftAuthTTL']
- : 5 * 60; // some sane number
+ : 15 * 60; // some sane number
$this->swiftTempUrlKey = isset( $config['swiftTempUrlKey'] )
? $config['swiftTempUrlKey']
: '';
@@ -537,6 +537,7 @@ class SwiftFileBackend extends FileBackendStore {
return $status; // already there
} elseif ( $stat === null ) {
$status->fatal( 'backend-fail-internal', $this->name );
+ wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
return $status;
}
@@ -568,6 +569,7 @@ class SwiftFileBackend extends FileBackendStore {
$status->fatal( 'backend-fail-usable', $params['dir'] );
} else {
$status->fatal( 'backend-fail-internal', $this->name );
+ wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
}
return $status;
@@ -588,6 +590,7 @@ class SwiftFileBackend extends FileBackendStore {
$status->fatal( 'backend-fail-usable', $params['dir'] );
} else {
$status->fatal( 'backend-fail-internal', $this->name );
+ wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
}
return $status;
@@ -607,6 +610,7 @@ class SwiftFileBackend extends FileBackendStore {
return $status; // ok, nothing to do
} elseif ( !is_array( $stat ) ) {
$status->fatal( 'backend-fail-internal', $this->name );
+ wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
return $status;
}
@@ -643,7 +647,7 @@ class SwiftFileBackend extends FileBackendStore {
$timestamp = new MWTimestamp( $ts );
return $timestamp->getTimestamp( $format );
- } catch ( MWException $e ) {
+ } catch ( Exception $e ) {
throw new FileBackendError( $e->getMessage() );
}
}
@@ -660,7 +664,7 @@ class SwiftFileBackend extends FileBackendStore {
return $objHdrs; // nothing to do
}
- $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
trigger_error( "$path was not stored with SHA-1 metadata.", E_USER_WARNING );
$auth = $this->getAuthentication();
@@ -794,7 +798,7 @@ class SwiftFileBackend extends FileBackendStore {
return $dirs; // nothing more
}
- $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$prefix = ( $dir == '' ) ? null : "{$dir}/";
// Non-recursive: only list dirs right under $dir
@@ -874,7 +878,7 @@ class SwiftFileBackend extends FileBackendStore {
return $files; // nothing more
}
- $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$prefix = ( $dir == '' ) ? null : "{$dir}/";
// $objects will contain a list of unfiltered names or CF_Object items
@@ -933,6 +937,7 @@ class SwiftFileBackend extends FileBackendStore {
// Convert various random Swift dates to TS_MW
'mtime' => $this->convertSwiftDate( $object->last_modified, TS_MW ),
'size' => (int)$object->bytes,
+ 'sha1' => null,
// Note: manifiest ETags are not an MD5 of the file
'md5' => ctype_xdigit( $object->hash ) ? $object->hash : null,
'latest' => false // eventually consistent
@@ -1060,6 +1065,7 @@ class SwiftFileBackend extends FileBackendStore {
$tmpFiles[$path] = $tmpFile;
}
+ $isLatest = ( $this->isRGW || !empty( $params['latest'] ) );
$opts = array( 'maxConnsPerHost' => $params['concurrency'] );
$reqs = $this->http->runMulti( $reqs, $opts );
foreach ( $reqs as $path => $op ) {
@@ -1074,6 +1080,10 @@ class SwiftFileBackend extends FileBackendStore {
$this->onError( null, __METHOD__,
array( 'src' => $path ) + $ep, $rerr, $rcode, $rdesc );
}
+ // Set the file stat process cache in passing
+ $stat = $this->getStatFromHeaders( $rhdrs );
+ $stat['latest'] = $isLatest;
+ $this->cheapCache->set( $path, 'stat', $stat );
} elseif ( $rcode === 404 ) {
$tmpFiles[$path] = false;
} else {
@@ -1161,6 +1171,11 @@ class SwiftFileBackend extends FileBackendStore {
return $hdrs;
}
+ /**
+ * @param FileBackendStoreOpHandle[] $fileOpHandles
+ *
+ * @return Status[]
+ */
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
$statuses = array();
@@ -1253,6 +1268,7 @@ class SwiftFileBackend extends FileBackendStore {
if ( $rcode != 204 && $rcode !== 202 ) {
$status->fatal( 'backend-fail-internal', $this->name );
+ wfDebugLog( 'SwiftBackend', __METHOD__ . ': unexpected rcode value (' . $rcode . ')' );
}
return $status;
@@ -1267,7 +1283,7 @@ class SwiftFileBackend extends FileBackendStore {
* @return array|bool|null False on 404, null on failure
*/
protected function getContainerStat( $container, $bypassCache = false ) {
- $section = new ProfileSection( __METHOD__ . '-' . $this->name );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
if ( $bypassCache ) { // purge cache
$this->containerStatCache->clear( $container );
@@ -1280,13 +1296,11 @@ class SwiftFileBackend extends FileBackendStore {
return null;
}
- wfProfileIn( __METHOD__ . "-{$this->name}-miss" );
list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array(
'method' => 'HEAD',
'url' => $this->storageUrl( $auth, $container ),
'headers' => $this->authTokenHeaders( $auth )
) );
- wfProfileOut( __METHOD__ . "-{$this->name}-miss" );
if ( $rcode === 204 ) {
$stat = array(
@@ -1507,25 +1521,8 @@ class SwiftFileBackend extends FileBackendStore {
if ( $rcode === 200 || $rcode === 204 ) {
// Update the object if it is missing some headers
$rhdrs = $this->addMissingMetadata( $rhdrs, $path );
- // Fetch all of the custom metadata headers
- $metadata = array();
- foreach ( $rhdrs as $name => $value ) {
- if ( strpos( $name, 'x-object-meta-' ) === 0 ) {
- $metadata[substr( $name, strlen( 'x-object-meta-' ) )] = $value;
- }
- }
- // Fetch all of the custom raw HTTP headers
- $headers = $this->sanitizeHdrs( array( 'headers' => $rhdrs ) );
- $stat = array(
- // Convert various random Swift dates to TS_MW
- 'mtime' => $this->convertSwiftDate( $rhdrs['last-modified'], TS_MW ),
- // Empty objects actually return no content-length header in Ceph
- 'size' => isset( $rhdrs['content-length'] ) ? (int)$rhdrs['content-length'] : 0,
- 'sha1' => $rhdrs['x-object-meta-sha1base36'],
- // Note: manifiest ETags are not an MD5 of the file
- 'md5' => ctype_xdigit( $rhdrs['etag'] ) ? $rhdrs['etag'] : null,
- 'xattr' => array( 'metadata' => $metadata, 'headers' => $headers )
- );
+ // Load the stat array from the headers
+ $stat = $this->getStatFromHeaders( $rhdrs );
if ( $this->isRGW ) {
$stat['latest'] = true; // strong consistency
}
@@ -1542,6 +1539,34 @@ class SwiftFileBackend extends FileBackendStore {
}
/**
+ * @param array $rhdrs
+ * @return array
+ */
+ protected function getStatFromHeaders( array $rhdrs ) {
+ // Fetch all of the custom metadata headers
+ $metadata = array();
+ foreach ( $rhdrs as $name => $value ) {
+ if ( strpos( $name, 'x-object-meta-' ) === 0 ) {
+ $metadata[substr( $name, strlen( 'x-object-meta-' ) )] = $value;
+ }
+ }
+ // Fetch all of the custom raw HTTP headers
+ $headers = $this->sanitizeHdrs( array( 'headers' => $rhdrs ) );
+ return array(
+ // Convert various random Swift dates to TS_MW
+ 'mtime' => $this->convertSwiftDate( $rhdrs['last-modified'], TS_MW ),
+ // Empty objects actually return no content-length header in Ceph
+ 'size' => isset( $rhdrs['content-length'] ) ? (int)$rhdrs['content-length'] : 0,
+ 'sha1' => isset( $rhdrs['x-object-meta-sha1base36'] )
+ ? $rhdrs['x-object-meta-sha1base36']
+ : null,
+ // Note: manifiest ETags are not an MD5 of the file
+ 'md5' => ctype_xdigit( $rhdrs['etag'] ) ? $rhdrs['etag'] : null,
+ 'xattr' => array( 'metadata' => $metadata, 'headers' => $headers )
+ );
+ }
+
+ /**
* @return array|null Credential map
*/
protected function getAuthentication() {
@@ -1595,7 +1620,7 @@ class SwiftFileBackend extends FileBackendStore {
}
// Ceph RGW does not use <account> in URLs (OpenStack Swift uses "/v1/<account>")
if ( substr( $this->authCreds['storage_url'], -3 ) === '/v1' ) {
- $this->isRGW = true; // take advantage of strong consistency
+ $this->isRGW = true; // take advantage of strong consistency in Ceph
}
}
diff --git a/includes/filebackend/TempFSFile.php b/includes/filebackend/TempFSFile.php
index 1b68130f..791be7fc 100644
--- a/includes/filebackend/TempFSFile.php
+++ b/includes/filebackend/TempFSFile.php
@@ -55,7 +55,6 @@ class TempFSFile extends FSFile {
* @return TempFSFile|null
*/
public static function factory( $prefix, $extension = '' ) {
- wfProfileIn( __METHOD__ );
$base = wfTempDir() . '/' . $prefix . wfRandomString( 12 );
$ext = ( $extension != '' ) ? ".{$extension}" : "";
for ( $attempt = 1; true; $attempt++ ) {
@@ -68,14 +67,12 @@ class TempFSFile extends FSFile {
break; // got it
}
if ( $attempt >= 5 ) {
- wfProfileOut( __METHOD__ );
return null; // give up
}
}
$tmpFile = new self( $path );
$tmpFile->autocollect(); // safely instantiated
- wfProfileOut( __METHOD__ );
return $tmpFile;
}
diff --git a/includes/filebackend/filejournal/FileJournal.php b/includes/filebackend/filejournal/FileJournal.php
index c0651485..4ee52220 100644
--- a/includes/filebackend/filejournal/FileJournal.php
+++ b/includes/filebackend/filejournal/FileJournal.php
@@ -57,14 +57,14 @@ abstract class FileJournal {
*
* @param array $config
* @param string $backend A registered file backend name
- * @throws MWException
+ * @throws Exception
* @return FileJournal
*/
final public static function factory( array $config, $backend ) {
$class = $config['class'];
$jrn = new $class( $config );
if ( !$jrn instanceof self ) {
- throw new MWException( "Class given is not an instance of FileJournal." );
+ throw new Exception( "Class given is not an instance of FileJournal." );
}
$jrn->backend = $backend;
diff --git a/includes/filebackend/lockmanager/DBLockManager.php b/includes/filebackend/lockmanager/DBLockManager.php
index 450ccc82..39a55635 100644
--- a/includes/filebackend/lockmanager/DBLockManager.php
+++ b/includes/filebackend/lockmanager/DBLockManager.php
@@ -52,7 +52,7 @@ abstract class DBLockManager extends QuorumLockManager {
/**
* Construct a new instance from configuration.
*
- * @param array $config Paramaters include:
+ * @param array $config Parameters include:
* - dbServers : Associative array of DB names to server configuration.
* Configuration is an associative array that includes:
* - host : DB server name
@@ -97,7 +97,7 @@ abstract class DBLockManager extends QuorumLockManager {
// connection timeouts. This is useless if each bucket has one peer.
try {
$this->statusCache = ObjectCache::newAccelerator( array() );
- } catch ( MWException $e ) {
+ } catch ( Exception $e ) {
trigger_error( __CLASS__ .
" using multiple DB peers without apc, xcache, or wincache." );
}
diff --git a/includes/filebackend/lockmanager/LockManager.php b/includes/filebackend/lockmanager/LockManager.php
index df8d2d4f..615ba77e 100644
--- a/includes/filebackend/lockmanager/LockManager.php
+++ b/includes/filebackend/lockmanager/LockManager.php
@@ -64,7 +64,7 @@ abstract class LockManager {
/**
* Construct a new instance from configuration
*
- * @param array $config Paramaters include:
+ * @param array $config Parameters include:
* - domain : Domain (usually wiki ID) that all resources are relative to [optional]
* - lockTTL : Age (in seconds) at which resource locks should expire.
* This only applies if locks are not tied to a connection/process.
@@ -72,9 +72,9 @@ abstract class LockManager {
public function __construct( array $config ) {
$this->domain = isset( $config['domain'] ) ? $config['domain'] : wfWikiID();
if ( isset( $config['lockTTL'] ) ) {
- $this->lockTTL = max( 1, $config['lockTTL'] );
+ $this->lockTTL = max( 5, $config['lockTTL'] );
} elseif ( PHP_SAPI === 'cli' ) {
- $this->lockTTL = 2 * 3600;
+ $this->lockTTL = 3600;
} else {
$met = ini_get( 'max_execution_time' ); // this is 0 in CLI mode
$this->lockTTL = max( 5 * 60, 2 * (int)$met );
@@ -102,7 +102,6 @@ abstract class LockManager {
* @since 1.22
*/
final public function lockByType( array $pathsByType, $timeout = 0 ) {
- wfProfileIn( __METHOD__ );
$status = Status::newGood();
$pathsByType = $this->normalizePathsByType( $pathsByType );
$msleep = array( 0, 50, 100, 300, 500 ); // retry backoff times
@@ -116,7 +115,6 @@ abstract class LockManager {
usleep( 1e3 * ( next( $msleep ) ?: 1000 ) ); // use 1 sec after enough times
$elapsed = microtime( true ) - $start;
} while ( $elapsed < $timeout && $elapsed >= 0 );
- wfProfileOut( __METHOD__ );
return $status;
}
@@ -140,10 +138,8 @@ abstract class LockManager {
* @since 1.22
*/
final public function unlockByType( array $pathsByType ) {
- wfProfileIn( __METHOD__ );
$pathsByType = $this->normalizePathsByType( $pathsByType );
$status = $this->doUnlockByType( $pathsByType );
- wfProfileOut( __METHOD__ );
return $status;
}
diff --git a/includes/filebackend/lockmanager/LockManagerGroup.php b/includes/filebackend/lockmanager/LockManagerGroup.php
index 19fc4fef..c72863ed 100644
--- a/includes/filebackend/lockmanager/LockManagerGroup.php
+++ b/includes/filebackend/lockmanager/LockManagerGroup.php
@@ -78,17 +78,17 @@ class LockManagerGroup {
* Register an array of file lock manager configurations
*
* @param array $configs
- * @throws MWException
+ * @throws Exception
*/
protected function register( array $configs ) {
foreach ( $configs as $config ) {
$config['domain'] = $this->domain;
if ( !isset( $config['name'] ) ) {
- throw new MWException( "Cannot register a lock manager with no name." );
+ throw new Exception( "Cannot register a lock manager with no name." );
}
$name = $config['name'];
if ( !isset( $config['class'] ) ) {
- throw new MWException( "Cannot register lock manager `{$name}` with no class." );
+ throw new Exception( "Cannot register lock manager `{$name}` with no class." );
}
$class = $config['class'];
unset( $config['class'] ); // lock manager won't need this
@@ -105,11 +105,11 @@ class LockManagerGroup {
*
* @param string $name
* @return LockManager
- * @throws MWException
+ * @throws Exception
*/
public function get( $name ) {
if ( !isset( $this->managers[$name] ) ) {
- throw new MWException( "No lock manager defined with the name `$name`." );
+ throw new Exception( "No lock manager defined with the name `$name`." );
}
// Lazy-load the actual lock manager instance
if ( !isset( $this->managers[$name]['instance'] ) ) {
@@ -126,11 +126,11 @@ class LockManagerGroup {
*
* @param string $name
* @return array
- * @throws MWException
+ * @throws Exception
*/
public function config( $name ) {
if ( !isset( $this->managers[$name] ) ) {
- throw new MWException( "No lock manager defined with the name `$name`." );
+ throw new Exception( "No lock manager defined with the name `$name`." );
}
$class = $this->managers[$name]['class'];
@@ -155,7 +155,7 @@ class LockManagerGroup {
* Throws an exception if no lock manager could be found.
*
* @return LockManager
- * @throws MWException
+ * @throws Exception
*/
public function getAny() {
return isset( $this->managers['default'] )
diff --git a/includes/filebackend/lockmanager/MemcLockManager.php b/includes/filebackend/lockmanager/MemcLockManager.php
index 9bb01c21..24d96e02 100644
--- a/includes/filebackend/lockmanager/MemcLockManager.php
+++ b/includes/filebackend/lockmanager/MemcLockManager.php
@@ -55,13 +55,13 @@ class MemcLockManager extends QuorumLockManager {
/**
* Construct a new instance from configuration.
*
- * @param array $config Paramaters include:
+ * @param array $config Parameters include:
* - lockServers : Associative array of server names to "<IP>:<port>" strings.
* - srvsByBucket : Array of 1-16 consecutive integer keys, starting from 0,
* each having an odd-numbered list of server names (peers) as values.
* - memcConfig : Configuration array for ObjectCache::newFromParams. [optional]
* If set, this must use one of the memcached classes.
- * @throws MWException
+ * @throws Exception
*/
public function __construct( array $config ) {
parent::__construct( $config );
@@ -80,7 +80,7 @@ class MemcLockManager extends QuorumLockManager {
if ( $cache instanceof MemcachedBagOStuff ) {
$this->bagOStuffs[$name] = $cache;
} else {
- throw new MWException(
+ throw new Exception(
'Only MemcachedBagOStuff classes are supported by MemcLockManager.' );
}
}
diff --git a/includes/filebackend/lockmanager/RedisLockManager.php b/includes/filebackend/lockmanager/RedisLockManager.php
index 90e05817..90e62e69 100644
--- a/includes/filebackend/lockmanager/RedisLockManager.php
+++ b/includes/filebackend/lockmanager/RedisLockManager.php
@@ -62,7 +62,7 @@ class RedisLockManager extends QuorumLockManager {
* - srvsByBucket : Array of 1-16 consecutive integer keys, starting from 0,
* each having an odd-numbered list of server names (peers) as values.
* - redisConfig : Configuration for RedisConnectionPool::__construct().
- * @throws MWException
+ * @throws Exception
*/
public function __construct( array $config ) {
parent::__construct( $config );