MediaWiki
REL1_19
|
Version of LockManager based on using DB table locks. More...
Public Member Functions | |
__construct (array $config) | |
Construct a new instance from configuration. | |
__destruct () | |
Make sure remaining locks get cleared for sanity. | |
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. | |
doLock (array $paths, $type) | |
doLockingQuery ($lockDb, array $paths, $type) | |
Get a connection to a lock DB and acquire locks on $paths. | |
doLockingQueryAll ($bucket, array $paths, $type) | |
Attempt to acquire locks with the peers for a bucket. | |
doUnlock (array $paths, $type) | |
finishLockTransactions () | |
Commit all changes to lock-active databases. | |
getBucketFromKey ($path) | |
Get the bucket for resource path. | |
getConnection ($lockDb) | |
Get (or reuse) a connection to a lock DB. | |
getMissKey ($lockDb) | |
Get a cache key for recent query misses for a DB. | |
initConnection ($lockDb, DatabaseBase $db) | |
Do additional initialization for new lock DB connection. | |
lastErrorIndicatesLocked ($lockDb) | |
Check if the last DB error for $lockDb indicates that a requested resource was locked by another process. | |
Protected Attributes | |
$conns = array() | |
$dbsByBucket | |
$dbServers | |
$lockExpiry | |
$safeDelay | |
$session = 0 | |
$statusCache |
Version of LockManager based on using DB table locks.
This is meant for multi-wiki systems that may share files. All locks are blocking, so it might be useful to set a small lock-wait timeout via server config to curtail deadlocks.
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 19 of file DBLockManager.php.
DBLockManager::__construct | ( | array $ | config | ) |
Construct a new instance from configuration.
$config paramaters include: 'dbServers' : Associative array of DB names to server configuration. Configuration is an associative array that includes: 'host' - DB server name 'dbname' - DB name 'type' - DB type (mysql,postgres,...) 'user' - DB user 'password' - DB user password 'tablePrefix' - DB table prefix 'flags' - DB flags (see DatabaseBase) 'dbsByBucket' : Array of 1-16 consecutive integer keys, starting from 0, each having an odd-numbered list of DB names (peers) as values. Any DB named 'localDBMaster' will automatically use the DB master settings for this wiki (without the need for a dbServers entry). 'lockExpiry' : Lock timeout (seconds) for dropped connections. [optional] This tells the DB server how long to wait before assuming connection failure and releasing all the locks for a session.
Array | $config |
Reimplemented from LockManager.
Definition at line 57 of file DBLockManager.php.
References wfBaseConvert(), and wfGetMainCache().
Make sure remaining locks get cleared for sanity.
Definition at line 388 of file DBLockManager.php.
DBLockManager::cacheCheckFailures | ( | $ | lockDb | ) | [protected] |
Checks if the DB has not recently had connection/query errors.
This just avoids wasting time on doomed connection attempts.
$lockDb | string |
Definition at line 335 of file DBLockManager.php.
References $path, and getMissKey().
Referenced by doLockingQueryAll().
DBLockManager::cacheRecordFailure | ( | $ | lockDb | ) | [protected] |
Log a lock request failure to the cache.
$lockDb | string |
Definition at line 350 of file DBLockManager.php.
References $path, and getMissKey().
Referenced by doLockingQueryAll().
DBLockManager::doLock | ( | array $ | paths, |
$ | type | ||
) | [protected] |
Reimplemented from LockManager.
Definition at line 94 of file DBLockManager.php.
References $path, $res, doLockingQueryAll(), doUnlock(), getBucketFromKey(), and Status\newGood().
DBLockManager::doLockingQuery | ( | $ | lockDb, |
array $ | paths, | ||
$ | type | ||
) | [protected] |
Get a connection to a lock DB and acquire locks on $paths.
This does not use GET_LOCK() per http://bugs.mysql.com/bug.php?id=1118.
$lockDb | string |
$paths | Array |
$type | integer LockManager::LOCK_EX or LockManager::LOCK_SH |
DBError |
Reimplemented in MySqlLockManager.
Definition at line 181 of file DBLockManager.php.
References $keys, and getConnection().
Referenced by doLockingQueryAll().
DBLockManager::doLockingQueryAll | ( | $ | bucket, |
array $ | paths, | ||
$ | type | ||
) | [protected] |
Attempt to acquire locks with the peers for a bucket.
This should avoid throwing any exceptions.
$bucket | integer |
$paths | Array List of resource keys to lock |
$type | integer LockManager::LOCK_EX or LockManager::LOCK_SH |
Definition at line 208 of file DBLockManager.php.
References cacheCheckFailures(), cacheRecordFailure(), doLockingQuery(), and lastErrorIndicatesLocked().
Referenced by doLock().
DBLockManager::doUnlock | ( | array $ | paths, |
$ | type | ||
) | [protected] |
Reimplemented from LockManager.
Definition at line 144 of file DBLockManager.php.
References $path, finishLockTransactions(), and Status\newGood().
Referenced by doLock().
DBLockManager::finishLockTransactions | ( | ) | [protected] |
Commit all changes to lock-active databases.
This should avoid throwing any exceptions.
Definition at line 298 of file DBLockManager.php.
References Status\newGood().
Referenced by doUnlock().
DBLockManager::getBucketFromKey | ( | $ | path | ) | [protected] |
Get the bucket for resource path.
This should avoid throwing any exceptions.
$path | string |
Definition at line 380 of file DBLockManager.php.
References $path.
Referenced by doLock().
DBLockManager::getConnection | ( | $ | lockDb | ) | [protected] |
Get (or reuse) a connection to a lock DB.
$lockDb | string |
DBError |
Definition at line 251 of file DBLockManager.php.
References $lb, $options, DatabaseBase\factory(), initConnection(), and wfGetLBFactory().
Referenced by doLockingQuery(), and MySqlLockManager\doLockingQuery().
DBLockManager::getMissKey | ( | $ | lockDb | ) | [protected] |
Get a cache key for recent query misses for a DB.
$lockDb | string |
Definition at line 369 of file DBLockManager.php.
Referenced by cacheCheckFailures(), and cacheRecordFailure().
DBLockManager::initConnection | ( | $ | lockDb, |
DatabaseBase $ | db | ||
) | [protected] |
Do additional initialization for new lock DB connection.
$lockDb | string |
$db | DatabaseBase |
DBError |
Reimplemented in MySqlLockManager.
Definition at line 290 of file DBLockManager.php.
Referenced by getConnection().
DBLockManager::lastErrorIndicatesLocked | ( | $ | lockDb | ) | [protected] |
Check if the last DB error for $lockDb indicates that a requested resource was locked by another process.
This should avoid throwing any exceptions.
$lockDb | string |
Definition at line 320 of file DBLockManager.php.
Referenced by doLockingQueryAll().
DBLockManager::$conns = array() [protected] |
Definition at line 32 of file DBLockManager.php.
DBLockManager::$dbsByBucket [protected] |
Definition at line 23 of file DBLockManager.php.
DBLockManager::$dbServers [protected] |
Definition at line 21 of file DBLockManager.php.
DBLockManager::$lockExpiry [protected] |
Definition at line 27 of file DBLockManager.php.
DBLockManager::$safeDelay [protected] |
Definition at line 28 of file DBLockManager.php.
DBLockManager::$session = 0 [protected] |
Definition at line 30 of file DBLockManager.php.
DBLockManager::$statusCache [protected] |
Definition at line 25 of file DBLockManager.php.