MediaWiki  REL1_22
DBLockManager Class Reference

Version of LockManager based on using named/row DB locks. More...

Inheritance diagram for DBLockManager:
Collaboration diagram for DBLockManager:

List of all members.

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.
 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, DatabaseBase $db)
 Do additional initialization for new lock DB connection.
 isServerUp ($lockSrv)

Protected Attributes

Array $conns = array()
 Map Database connections (DB name => Database) *.
Array $dbServers
 Map of DB names to server config *.
 $lockExpiry
 $safeDelay
 $session = 0
BagOStuff $statusCache
 *

Detailed Description

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.

Since:
1.19

Definition at line 39 of file DBLockManager.php.


Constructor & Destructor Documentation

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). Only use 'localDBMaster' if the domain is a valid wiki ID.
  • 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.
Parameters:
array$config

Reimplemented from LockManager.

Definition at line 73 of file DBLockManager.php.

Make sure remaining locks get cleared for sanity.

Definition at line 227 of file DBLockManager.php.


Member Function Documentation

DBLockManager::cacheCheckFailures ( lockDb) [protected]

Checks if the DB has not recently had connection/query errors.

This just avoids wasting time on doomed connection attempts.

Parameters:
$lockDbstring
Returns:
bool

Definition at line 195 of file DBLockManager.php.

DBLockManager::cacheRecordFailure ( lockDb) [protected]

Log a lock request failure to the cache.

Parameters:
$lockDbstring
Returns:
bool Success

Definition at line 207 of file DBLockManager.php.

DBLockManager::freeLocksOnServer ( lockSrv,
array pathsByType 
) [protected]

Get a connection to a lock server and release locks on $paths.

Subclasses must effectively implement this or releaseAllLocks().

Parameters:
$lockSrvstring
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns:
Status

Reimplemented from QuorumLockManager.

Definition at line 119 of file DBLockManager.php.

DBLockManager::getConnection ( lockDb) [protected]

Get (or reuse) a connection to a lock DB.

Parameters:
$lockDbstring
Returns:
DatabaseBase
Exceptions:
DBError

Definition at line 147 of file DBLockManager.php.

DBLockManager::getLocksOnServer ( lockSrv,
array pathsByType 
) [protected]

Get a connection to a lock server and acquire locks.

Parameters:
$lockSrvstring
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns:
Status

Reimplemented from QuorumLockManager.

Definition at line 111 of file DBLockManager.php.

DBLockManager::getMissKey ( lockDb) [protected]

Get a cache key for recent query misses for a DB.

Parameters:
$lockDbstring
Returns:
string

Definition at line 219 of file DBLockManager.php.

DBLockManager::initConnection ( lockDb,
DatabaseBase db 
) [protected]

Do additional initialization for new lock DB connection.

Parameters:
$lockDbstring
$dbDatabaseBase
Returns:
void
Exceptions:
DBError

Reimplemented in MySqlLockManager.

Definition at line 186 of file DBLockManager.php.

DBLockManager::isServerUp ( lockSrv) [protected]
See also:
QuorumLockManager::isServerUp()
Returns:
bool

Reimplemented from QuorumLockManager.

Definition at line 127 of file DBLockManager.php.


Member Data Documentation

Array DBLockManager::$conns = array() [protected]

Map Database connections (DB name => Database) *.

Definition at line 47 of file DBLockManager.php.

Array DBLockManager::$dbServers [protected]

Map of DB names to server config *.

Definition at line 40 of file DBLockManager.php.

DBLockManager::$lockExpiry [protected]

Definition at line 43 of file DBLockManager.php.

DBLockManager::$safeDelay [protected]

Definition at line 44 of file DBLockManager.php.

DBLockManager::$session = 0 [protected]

Definition at line 46 of file DBLockManager.php.

BagOStuff DBLockManager::$statusCache [protected]

*

Definition at line 41 of file DBLockManager.php.


The documentation for this class was generated from the following file: