Merge "Simpler RedisLockManager configuration"
This commit is contained in:
commit
395e60b088
5 changed files with 43 additions and 19 deletions
|
|
@ -583,7 +583,15 @@ $wgImgAuthUrlPathMap = [];
|
|||
*
|
||||
* - name A unique name for the repository (but $wgLocalFileRepo should be 'local').
|
||||
* The name should consist of alpha-numeric characters.
|
||||
* - backend A file backend name (see $wgFileBackends).
|
||||
*
|
||||
* Optional common properties:
|
||||
* - backend A file backend name (see $wgFileBackends). If not specified, or
|
||||
* if the name is not present in $wgFileBackends, an FSFileBackend
|
||||
* will automatically be configured.
|
||||
* - lockManager If a file backend is automatically configured, this will be lock
|
||||
* manager name used. A lock manager named in $wgLockManagers, or one of
|
||||
* the default lock managers "fsLockManager" or "nullLockManager". Default
|
||||
* "fsLockManager".
|
||||
*
|
||||
* For most core repos:
|
||||
* - zones Associative array of zone names that each map to an array with:
|
||||
|
|
|
|||
|
|
@ -118,11 +118,12 @@ class FileBackendGroup {
|
|||
$deletedDir = $info['deletedDir'] ?? false; // deletion disabled
|
||||
$thumbDir = $info['thumbDir'] ?? "{$directory}/thumb";
|
||||
$transcodedDir = $info['transcodedDir'] ?? "{$directory}/transcoded";
|
||||
$lockManager = $info['lockManager'] ?? 'fsLockManager';
|
||||
// Get the FS backend configuration
|
||||
$autoBackends[] = [
|
||||
'name' => $backendName,
|
||||
'class' => FSFileBackend::class,
|
||||
'lockManager' => 'fsLockManager',
|
||||
'lockManager' => $lockManager,
|
||||
'containerPaths' => [
|
||||
"{$repoName}-public" => "{$directory}",
|
||||
"{$repoName}-thumb" => $thumbDir,
|
||||
|
|
|
|||
|
|
@ -65,8 +65,9 @@ abstract class DBLockManager extends QuorumLockManager {
|
|||
* - password : DB user password
|
||||
* - tablePrefix : DB table prefix
|
||||
* - flags : DB flags; bitfield of IDatabase::DBO_* constants
|
||||
* - dbsByBucket : Array of 1-16 consecutive integer keys, starting from 0,
|
||||
* each having an odd-numbered list of DB names (peers) as values.
|
||||
* - dbsByBucket : An array of up to 16 arrays, each containing the DB names
|
||||
* in a bucket. Each bucket should have an odd number of servers.
|
||||
* If omitted, all DBs will be in one bucket. (optional).
|
||||
* - 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.
|
||||
|
|
@ -76,9 +77,13 @@ abstract class DBLockManager extends QuorumLockManager {
|
|||
parent::__construct( $config );
|
||||
|
||||
$this->dbServers = $config['dbServers'];
|
||||
// Sanitize srvsByBucket config to prevent PHP errors
|
||||
$this->srvsByBucket = array_filter( $config['dbsByBucket'], 'is_array' );
|
||||
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
|
||||
if ( isset( $config['dbsByBucket'] ) ) {
|
||||
// Sanitize srvsByBucket config to prevent PHP errors
|
||||
$this->srvsByBucket = array_filter( $config['dbsByBucket'], 'is_array' );
|
||||
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
|
||||
} else {
|
||||
$this->srvsByBucket = [ array_keys( $this->dbServers ) ];
|
||||
}
|
||||
|
||||
if ( isset( $config['lockExpiry'] ) ) {
|
||||
$this->lockExpiry = $config['lockExpiry'];
|
||||
|
|
|
|||
|
|
@ -54,8 +54,9 @@ class MemcLockManager extends QuorumLockManager {
|
|||
*
|
||||
* @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.
|
||||
* - srvsByBucket : An array of up to 16 arrays, each containing the server names
|
||||
* in a bucket. Each bucket should have an odd number of servers.
|
||||
* If omitted, all servers will be in one bucket. [optional].
|
||||
* - memcConfig : Configuration array for MemcachedBagOStuff::construct() with an
|
||||
* additional 'class' parameter specifying which MemcachedBagOStuff
|
||||
* subclass to use. The server names will be injected. [optional]
|
||||
|
|
@ -64,9 +65,13 @@ class MemcLockManager extends QuorumLockManager {
|
|||
public function __construct( array $config ) {
|
||||
parent::__construct( $config );
|
||||
|
||||
// Sanitize srvsByBucket config to prevent PHP errors
|
||||
$this->srvsByBucket = array_filter( $config['srvsByBucket'], 'is_array' );
|
||||
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
|
||||
if ( isset( $config['srvsByBucket'] ) ) {
|
||||
// Sanitize srvsByBucket config to prevent PHP errors
|
||||
$this->srvsByBucket = array_filter( $config['srvsByBucket'], 'is_array' );
|
||||
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
|
||||
} else {
|
||||
$this->srvsByBucket = [ array_keys( $config['lockServers'] ) ];
|
||||
}
|
||||
|
||||
$memcConfig = $config['memcConfig'] ?? [];
|
||||
$memcConfig += [ 'class' => MemcachedPhpBagOStuff::class ]; // default
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
* bucket. Each bucket maps to one or several peer servers, each running redis.
|
||||
* A majority of peers must agree for a lock to be acquired.
|
||||
*
|
||||
* This class requires Redis 2.6 as it makes use Lua scripts for fast atomic operations.
|
||||
* This class requires Redis 2.6 as it makes use of Lua scripts for fast atomic operations.
|
||||
*
|
||||
* @ingroup LockManager
|
||||
* @since 1.22
|
||||
|
|
@ -56,18 +56,23 @@ class RedisLockManager extends QuorumLockManager {
|
|||
*
|
||||
* @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.
|
||||
* - redisConfig : Configuration for RedisConnectionPool::__construct().
|
||||
* - srvsByBucket : An array of up to 16 arrays, each containing the server names
|
||||
* in a bucket. Each bucket should have an odd number of servers.
|
||||
* If omitted, all servers will be in one bucket. (optional).
|
||||
* - redisConfig : Configuration for RedisConnectionPool::singleton() (optional).
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct( array $config ) {
|
||||
parent::__construct( $config );
|
||||
|
||||
$this->lockServers = $config['lockServers'];
|
||||
// Sanitize srvsByBucket config to prevent PHP errors
|
||||
$this->srvsByBucket = array_filter( $config['srvsByBucket'], 'is_array' );
|
||||
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
|
||||
if ( isset( $config['srvsByBucket'] ) ) {
|
||||
// Sanitize srvsByBucket config to prevent PHP errors
|
||||
$this->srvsByBucket = array_filter( $config['srvsByBucket'], 'is_array' );
|
||||
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
|
||||
} else {
|
||||
$this->srvsByBucket = [ array_keys( $this->lockServers ) ];
|
||||
}
|
||||
|
||||
$config['redisConfig']['serializer'] = 'none';
|
||||
$this->redisPool = RedisConnectionPool::singleton( $config['redisConfig'] );
|
||||
|
|
|
|||
Loading…
Reference in a new issue