MediaWiki REL1_27
|
Version of LockManager based on using named/row DB locks. More...
Public Member Functions | |
__construct (array $config) | |
Construct a new instance from configuration. | |
__destruct () | |
Make sure remaining locks get cleared for sanity. | |
![]() | |
lock (array $paths, $type=self::LOCK_EX, $timeout=0) | |
Lock the resources at the given abstract paths. | |
lockByType (array $pathsByType, $timeout=0) | |
Lock the resources at the given abstract paths. | |
unlock (array $paths, $type=self::LOCK_EX) | |
Unlock the resources at the given abstract paths. | |
unlockByType (array $pathsByType) | |
Unlock the resources at the given abstract paths. | |
Protected Member Functions | |
cacheCheckFailures ( $lockDb) | |
Checks if the DB has not recently had connection/query errors. | |
cacheRecordFailure ( $lockDb) | |
Log a lock request failure to the cache. | |
freeLocksOnServer ( $lockSrv, array $pathsByType) | |
Get a connection to a lock server and release locks on $paths. | |
getConnection ( $lockDb) | |
Get (or reuse) a connection to a lock DB. | |
getLocksOnServer ( $lockSrv, array $pathsByType) | |
Get a connection to a lock server and acquire locks. | |
getMissKey ( $lockDb) | |
Get a cache key for recent query misses for a DB. | |
initConnection ( $lockDb, IDatabase $db) | |
Do additional initialization for new lock DB connection. | |
isServerUp ( $lockSrv) | |
![]() | |
doLock (array $paths, $type) | |
Lock resources with the given keys and lock type. | |
doLockByType (array $pathsByType) | |
doLockingRequestBucket ( $bucket, array $pathsByType) | |
Attempt to acquire locks with the peers for a bucket. | |
doUnlock (array $paths, $type) | |
Unlock resources with the given keys and lock type. | |
doUnlockByType (array $pathsByType) | |
doUnlockingRequestBucket ( $bucket, array $pathsByType) | |
Attempt to release locks with the peers for a bucket. | |
getBucketFromPath ( $path) | |
Get the bucket for resource path. | |
releaseAllLocks () | |
Release all locks that this session is holding. | |
![]() | |
normalizePathsByType (array $pathsByType) | |
Normalize the $paths array by converting LOCK_UW locks into the appropriate type and removing any duplicated paths for each lock type. | |
sha1Base16Absolute ( $path) | |
Get the base 16 SHA-1 of a string, padded to 31 digits. | |
sha1Base36Absolute ( $path) | |
Get the base 36 SHA-1 of a string, padded to 31 digits. | |
Protected Attributes | |
array | $conns = [] |
Map Database connections (DB name => Database) | |
array | $dbServers |
Map of DB names to server config. | |
$lockExpiry | |
$safeDelay | |
$session = 0 | |
BagOStuff | $statusCache |
![]() | |
array | $degradedBuckets = [] |
Map of degraded buckets. | |
array | $srvsByBucket = [] |
Map of bucket indexes to peer server lists. | |
![]() | |
$domain | |
array | $locksHeld = [] |
Map of (resource path => lock type => count) | |
$lockTTL | |
array | $lockTypeMap |
Mapping of lock types to the type actually used. | |
Additional Inherited Members | |
![]() | |
const | LOCK_EX = 3 |
const | LOCK_SH = 1 |
Lock types; stronger locks have higher values. | |
const | LOCK_UW = 2 |
Version of LockManager based on using named/row DB locks.
This is meant for multi-wiki systems that may share files.
All lock requests for a resource, identified by a hash string, will map to one bucket. Each bucket maps to one or several peer DBs, each on their own server, all having the filelocks.sql tables (with row-level locking). A majority of peer DBs must agree for a lock to be acquired.
Caching is used to avoid hitting servers that are down.
Definition at line 39 of file DBLockManager.php.
DBLockManager::__construct | ( | array | $config | ) |
Construct a new instance from configuration.
array | $config | Parameters include:
|
Reimplemented from LockManager.
Definition at line 74 of file DBLockManager.php.
References $lockExpiry, as, ObjectCache\getLocalServerInstance(), and wfRandomString().
DBLockManager::__destruct | ( | ) |
Make sure remaining locks get cleared for sanity.
Definition at line 228 of file DBLockManager.php.
References as, and QuorumLockManager\releaseAllLocks().
|
protected |
Checks if the DB has not recently had connection/query errors.
This just avoids wasting time on doomed connection attempts.
string | $lockDb |
Definition at line 196 of file DBLockManager.php.
References getMissKey().
Referenced by isServerUp().
|
protected |
Log a lock request failure to the cache.
string | $lockDb |
Definition at line 208 of file DBLockManager.php.
References getMissKey().
Referenced by isServerUp().
|
protected |
Get a connection to a lock server and release locks on $paths.
Subclasses must effectively implement this or releaseAllLocks().
string | $lockSrv | |
array | $pathsByType | Map of LockManager::LOCK_* constants to lists of paths |
Reimplemented from QuorumLockManager.
Definition at line 116 of file DBLockManager.php.
|
protected |
Get (or reuse) a connection to a lock DB.
string | $lockDb |
DBError |
Definition at line 147 of file DBLockManager.php.
References $lockExpiry, $options, DB_MASTER, DBO_TRX, DatabaseBase\factory(), initConnection(), and wfGetLBFactory().
Referenced by MySqlLockManager\doGetLocksOnServer(), PostgreSqlLockManager\doGetLocksOnServer(), and isServerUp().
|
protected |
Get a connection to a lock server and acquire locks.
string | $lockSrv | |
array | $pathsByType | Map of LockManager::LOCK_* constants to lists of paths |
Reimplemented from QuorumLockManager.
Definition at line 107 of file DBLockManager.php.
|
protected |
Get a cache key for recent query misses for a DB.
string | $lockDb |
Definition at line 220 of file DBLockManager.php.
References wfWikiID().
Referenced by cacheCheckFailures(), and cacheRecordFailure().
|
protected |
Do additional initialization for new lock DB connection.
string | $lockDb | |
IDatabase | $db |
DBError |
Reimplemented in MySqlLockManager.
Definition at line 186 of file DBLockManager.php.
Referenced by getConnection().
|
protected |
string | $lockSrv |
Reimplemented from QuorumLockManager.
Definition at line 125 of file DBLockManager.php.
References $e, cacheCheckFailures(), cacheRecordFailure(), and getConnection().
|
protected |
Map Database connections (DB name => Database)
Definition at line 50 of file DBLockManager.php.
|
protected |
Map of DB names to server config.
Definition at line 41 of file DBLockManager.php.
|
protected |
Definition at line 45 of file DBLockManager.php.
Referenced by __construct(), and getConnection().
|
protected |
Definition at line 46 of file DBLockManager.php.
|
protected |
Definition at line 48 of file DBLockManager.php.
Referenced by MySqlLockManager\doGetLocksOnServer().
|
protected |
Definition at line 43 of file DBLockManager.php.