Page MenuHomePhabricator

CirrusSearch index names in cluster can conflict
Closed, ResolvedPublic

Description

I run Mediawiki with three wikis.
the names of the wikis are: en, de, adb

CirrusSearch creates these indices (indexes):
wikidb-en __ general_first
wikidb-en __ content_first
wikidb-de __ general_first
wikidb-de __ content_first
wikidb-adb __ general_first
wikidb-adb __ content_first

Now I have the same installation on a test machine, lets call it t1, and on a production machine, p1.
The test machine usually contains an older, not active copy of the wikis.

I run elasticsearch on each of the two machines, and they have the same index names for the wiki indexes.

This means that I cannot let Elasticsearch form a cluster between the two machines, though I would like that to profit from the automatic backup of the indexes this provides.

But because they have the same index names, Elasticsearch gets confused, as it starts to merge the two sets of indexes.

What would help me if I could give different index names to the indexes CirrusSearch makes on the two machines.

I do not want to give the wikis different names, between the test and production machines.

How can one influence that names CirrusSearch and Elastica give to the indexes?

Event Timeline

currently no support exists for this feature. Could probably add some hack to extensions/Elastica/ElasticaConnection.php in the getIndexName() method to prefix with something though. I think that would cover all use cases, but would have to try it out and see that everything really does go through that method like it should.

@EBernhardson, yes it seems to work.
I defined a prefix 'wwi_' and let the function retrn $prefix . $name

Then I run CirrusSearch/maintenance
php updateSearchIndexConfig.php --startOver
php forceSearchIndex.php

Marvel plugin shows the new indexes
wwi_mw_cirrus_versions
wwi_wikidb-en __ content_first
wwi_wikidb-en __ general_first
and search works, also after I delete the previous indexes via Elasticsearch commands.

It will be easy to define such a prefix via $wgElasticaIndexPrefix

My function getIndexName reads now:
public function getIndexName( $name, $type = false, $identifier = false ) {

        global $wgElasticaIndexPrefix;  //Alois
        if ( $type ) {
                $name .= '_' . $type;
        }
        if ( $identifier ) {
                $name .= '_' . $identifier;
        }
        if ( isset($wgElasticaIndexPrefix) ) {  //Alois 3 lines
          return $wgElasticaIndexPrefix.$name;
        }
        return $name;
}

In LocalSettings.php I have
// created by Alois for extensions/Elastica/ElasticaConnection.php
$wgElasticaIndexPrefix = 'wwi_';

Glad that worked for you! I'm going to make some changes soon to allow explicitly setting per-wiki index prefixes rather than using the wiki name (although that will stay the default). That work will be attached to T140434

debt claimed this task.
debt subscribed.

resolving this for now - looks like there is a good work-around for this and the next fix in T140434 will fix this more thoroughly.