Page MenuHomePhabricator

Add support for Redis database selection in MediaWiki RedisBagOStuff
Closed, DeclinedPublic


The REDIS backend RedisConnectionPool.php and RedisBagOStuff.php do not support to select a DB index.

I'd like to add an additional connection option that allows just that. How do you like the option name dbindex?


$wgObjectCaches['redis'] = array(
    'class'                => 'RedisBagOStuff',
    'servers'              => array( '' ),
    // 'connectTimeout'    => 1,
    // 'persistent'        => false,
    // 'password'          => 'secret',
    // 'automaticFailOver' => true,
    // 'dbindex'           => 0,

I can code it myself and send a PR. What do you think?

Related Objects

Event Timeline

Change 617123 had a related patch set uploaded (by Hyperzlib; owner: Hyperzlib):
[mediawiki/core@master] redis, objectcache: Allow using 'db' option to select redis database.

Krinkle renamed this task from RedisBagOStuff does not allow to select DB index to Add support for Redis database selection in MediaWiki RedisBagOStuff.EditedAug 12 2020, 2:26 AM
Krinkle added a project: Platform Engineering.
Krinkle subscribed.

I'm not entirely sure what this is for since MediaWiki generally does namespacing by prefix instead of separate DBs. What is the benefit or motivation for wanting this? Are there separate security/permission credentials?

Tagging PE to decide on this further.

@Krinkle @eprodromou This would be useful to have. This isn't a security feature since can't say that a particular client only has access to a particular database, but more an interoperability feature with other (non-MediaWiki) applications that are making use of the same redis instance just in case they happen to use the same keyspaces (unlikely, but possible). It could also be useful when sharing a single redis instance across multiple MediaWiki installations where it's desired to not share certain things (such as rate limits) across all of those wikis because they are meant to be independent and not part of a farm.

Both uses cases caused me to comment here as I was looking into a way to select the database index and stumbled across this task. I'm hosting a handful of independent wikis where I do not wish to share rate limiting information between them. I'm also hosting some non-MediaWiki applications that can make use of redis, and I didn't want to have to dig into the code for all of them to ensure there would be no possible overlap in the namespaces used in keys.

While I could spin up multiple redis instances (one per application), it'd be far easier from a systems management perspective to have a single instance for everything.

The feature seems to be discouraged* by the author of redis, and doesn't gain much over key prefixes (MediaWiki code using BagOStuff already uses ones based on $wgDBname/$wgDBprefix and configurable IDs) or multiple redis instances.

Change 617123 abandoned by Krinkle:

[mediawiki/core@master] redis, objectcache: Allow using 'db' option to select redis database.


Per task