•  
      request #27513 Deal with database patterns
    Infos
    #27513
    Manuel Vacelet (vaceletm)
    2022-09-08 15:29
    2022-06-24 15:50
    29058
    Details
    Deal with database patterns

    At the time of writing, Tuleap Legacy Mediawiki has two databases patterns:

    • One database per project (plugin_mediawiki_$PROJID)
    • One tableset per project (one database plugin_mediawiki and for each project a set of tables with $wgDBprefix

    On Mediawiki Standalone side

    • There is now one database dedicated to farm management (plugin_mediawiki_standalone_farm)
    • One database per project (plugin_mediawiki_$PROJID)

    We need to understand how we can setup the standalone MW with a fixed number of databases (ie without having the possibility to create databases on the fly):

    • Can we have the central mediawiki database & usage of $wgDBprefix ?
    • Is plugin_mediawiki_standalone_farm mandatory or could it be in central database as well ?
    Mediawiki Standalone
    Empty
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Robert Vogel (rvogel), Dejan Savuljesku (dsavuljesku)
    Stage
    Robert Vogel (rvogel)
    Closed
    2022-09-08
    Attachments
    Empty
    References
    Referencing request #27513

    Follow-ups

    User avatar

    I have created a new patch for this issue: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/TuleapWikiFarm/+/818065

    Now the behaviour is changed! Instead of using a bool useSingleDb, this option is now renamed to centralDb and its value is either a null(default, no central DB is used, each instance gets separate DB), or a string specifying the DB name to be used as central DB. My reasoning was that using the "farm" DB for shared instance DB is not such a good idea anyways, and since there is a need to manually specify which DB should serve as the "central" DB, this makes more sense to me.

    User avatar

    Did you a chance to look at this ?

    I made a prototype here: https://gerrit.tuleap.net/c/tuleap/+/26427 and I still have a dedicated database that is created instead of prefix.

    Plus, in term of migrations, it should be possible to specify/configure a dedicated database instead of the farm one (aka plugin_mediawiki_standalone_farm) because right now the platforms that have "central database" already have their data inside a dedicated DB.

    User avatar
    Robert Vogel (rvogel)2022-07-18 18:05

    Yes, it would be plugin_mediawiki_standalone_farm, or whatever is set as $wgDBname for the "main instance".

    User avatar
    last edited by: Manuel Vacelet (vaceletm) 2022-07-18 17:46

    Dejan wrote

    This will use "main" DB for all wikis, and having unique dbPrefix for each instance. In this mode, PUT call to instance must contain "dbprefix" param.

    Maybe this was not the expectation in the first place?

    I maybe should have asked this question first: what do you mean by "main" db ? :) is that plugin_mediawiki_standalone_farm ?

    User avatar
    Robert Vogel (rvogel)2022-07-18 17:42
    last edited by: Robert Vogel (rvogel) 2022-07-18 17:42

    Regarding:

    Plus, I find it strange that I don't have to specify the database to use for the single db.

    Dejan wrote

    This will use "main" DB for all wikis, and having unique dbPrefix for each instance. In this mode, PUT call to instance must contain "dbprefix" param.

    Maybe this was not the expectation in the first place?

    Regarding:

    However, instance creation still creates a plugin_mediawiki_101 database. What did I forget ?

    I will check and report back as soon as possible.

    User avatar

    @rvogel I have set the following in /etc/tuleap/plugins/mediawiki_standalone/LocalSettings.local.php:

    $GLOBALS['wgTuleapFarmConfig']['useSingleDb'] = true;
    

    plus modified plugins/mediawiki_standalone/include/Instance/CreateInstance.php to add dbprefix:

    $request = $request_factory->createRequest('PUT', ServerHostname::HTTPSUrl() . '/mediawiki/w/rest.php/tuleap/instance/' . urlencode($this->project->getUnixNameLowerCase()))
                ->withBody(
                    HTTPFactoryBuilder::streamFactory()->createStream(
                        \json_encode(
                            [
                                'project_id' => (int) $this->project->getID(),
                                'dbprefix' => 'mw_' . $this->project->getID() . '_',
                            ],
                            JSON_THROW_ON_ERROR
                        )
                    )
                );
    

    However, instance creation still creates a plugin_mediawiki_101 database. What did I forget ?

    Plus, I find it strange that I don't have to specify the database to use for the single db.

    User avatar

    Done in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/TuleapWikiFarm/+/809999 Needs proper testing after review

    To set "single db" mode, set $wgTuleapFarmConfig['useSingleDb'] = true; This will use "main" DB for all wikis, and having unique dbPrefix for each instance. In this mode, PUT call to instance must contain "dbprefix" param.

    DB schema change, tuleap_instances table must be dropped, and maintenance/update.php run, to re-create the table with new schema!