Jump to content

Topic on Extension talk:Wikibase Client

Cannot access the database after upgrade to MediaWiki 1.31.0

11
Till Kraemer (talkcontribs)

Hi, I just upgraded to MediaWiki 1.31.0. My repo works fine, however, when I try to load an article on the client wiki, I get the following error:

Sorry! This site is experiencing technical difficulties.

Try waiting a few minutes and reloading.

(Cannot access the database)

Backtrace:

#0 /path/to/mywikis/pool/w/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1134): Wikimedia\Rdbms\Database->reportConnectionError('Unknown databas...')
#1 /path/to/mywikis/pool/w/includes/libs/rdbms/loadbalancer/LoadBalancer.php(749): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()
#2 /path/to/mywikis/pool/w/includes/dao/DBAccessBase.php(64): Wikimedia\Rdbms\LoadBalancer->getConnection(0, Array, 'repo')
#3 /path/to/mywikis/pool/w/extensions/Wikibase/lib/includes/Store/Sql/SiteLinkTable.php(221): DBAccessBase->getConnection(-1)
#4 /path/to/mywikis/pool/w/extensions/Wikibase/lib/includes/Store/CachingSiteLinkLookup.php(147): Wikibase\Lib\Store\Sql\SiteLinkTable->getItemIdForLink('poolwiki', 'Main Page')
#5 /path/to/mywikis/pool/w/extensions/Wikibase/lib/includes/Store/CachingSiteLinkLookup.php(75): Wikibase\Lib\Store\CachingSiteLinkLookup->getAndCacheItemIdForLink('poolwiki', 'Main Page')
#6 /path/to/mywikis/pool/w/extensions/Wikibase/client/includes/LangLinkHandler.php(101): Wikibase\Lib\Store\CachingSiteLinkLookup->getItemIdForLink('poolwiki', 'Main Page')
#7 /path/to/mywikis/pool/w/extensions/Wikibase/client/includes/LangLinkHandler.php(331): Wikibase\Client\LangLinkHandler->getEntityLinks(Object(Title))
#8 /path/to/mywikis/pool/w/extensions/Wikibase/client/includes/LangLinkHandler.php(352): Wikibase\Client\LangLinkHandler->getEffectiveRepoLinks(Object(Title), Object(ParserOutput))
#9 /path/to/mywikis/pool/w/extensions/Wikibase/client/includes/Hooks/ParserOutputUpdateHookHandlers.php(97): Wikibase\Client\LangLinkHandler->addLinksFromRepository(Object(Title), Object(ParserOutput))
#10 /path/to/mywikis/pool/w/extensions/Wikibase/client/includes/Hooks/ParserOutputUpdateHookHandlers.php(65): Wikibase\Client\Hooks\ParserOutputUpdateHookHandlers->doContentAlterParserOutput(Object(Title), Object(ParserOutput))
#11 /path/to/mywikis/pool/w/includes/Hooks.php(177): Wikibase\Client\Hooks\ParserOutputUpdateHookHandlers::onContentAlterParserOutput(Object(WikitextContent), Object(Title), Object(ParserOutput))
#12 /path/to/mywikis/pool/w/includes/Hooks.php(205): Hooks::callHook('ContentAlterPar...', Array, Array, NULL)
#13 /path/to/mywikis/pool/w/includes/content/AbstractContent.php(520): Hooks::run('ContentAlterPar...', Array)
#14 /path/to/mywikis/pool/w/includes/poolcounter/PoolWorkArticleView.php(144): AbstractContent->getParserOutput(Object(Title), 7803, Object(ParserOptions))
#15 /path/to/mywikis/pool/w/includes/poolcounter/PoolCounterWork.php(123): PoolWorkArticleView->doWork()
#16 /path/to/mywikis/pool/w/includes/page/Article.php(604): PoolCounterWork->execute()
#17 /path/to/mywikis/pool/w/includes/actions/ViewAction.php(68): Article->view()
#18 /path/to/mywikis/pool/w/includes/MediaWiki.php(500): ViewAction->show()
#19 /path/to/mywikis/pool/w/includes/MediaWiki.php(294): MediaWiki->performAction(Object(Article), Object(Title))
#20 /path/to/mywikis/pool/w/includes/MediaWiki.php(861): MediaWiki->performRequest()
#21 /path/to/mywikis/pool/w/includes/MediaWiki.php(524): MediaWiki->main()
#22 /path/to/mywikis/pool/w/index.php(42): MediaWiki->run()
#23 {main}

The local database can be accessed perfectly, special pages like recent changes or user contributions show up properly, but somehow the repo database can't be accessed anymore :/

Any ideas are more than appreciated! Thanks and cheers!

Thiemo Kreuz (WMDE) (talkcontribs)

Did you made sure to run the update.php maintenance script on both the repo and the client database?

Till Kraemer (talkcontribs)

Hi @Thiemo Kreuz (WMDE), thanks for your reply! Yeah, I ran the update script and I just did it again, just to make sure. Same error :/ With older MediaWiki versions I used the Wikidata extension bundle, but it seems to be discontinued. This time, I installed Wikibase using Composer as suggested.

I just noticed that Wikipedia uses WikimediaBadges and WikibaseLexeme, so I wanted to install them too, just in case. Wasn't able to install WikibaseLexeme on the client wiki though. Showed me a blank page.

The LocalSettings.php on the client wiki looks like this:

# Wikibase Extension
$wgEnableWikibaseRepo = false;
$wgEnableWikibaseClient = true;
#$wmgUseWikibaseRepo = false;
#$wmgUseWikibaseClient = true;
#require_once __DIR__ . "/extensions/Wikidata/Wikidata.php";
#require_once __DIR__ . "/extensions/Wikidata/extensions/Wikibase/repo/ExampleSettings.php";
require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
#require_once "$IP/extensions/Wikibase/repo/Wikibase.php";
#require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";

# Settings
$wgWBClientSettings['repoUrl'] = 'https://data.mywiki.com';
$wgWBClientSettings['repoScriptPath'] = '/w';
$wgWBClientSettings['repoArticlePath'] = '/wiki/$1';
$wgWBClientSettings['siteGlobalID'] = 'enwiki';
$wgWBClientSettings['repoDatabase'] = 'datawiki';
$wgWBClientSettings['changesDatabase'] = 'datawiki';
#$wgWBClientSettings['siteLinkGroups'] = 'mywiki';
$wgWBClientSettings['repoSiteId'] = 'datawiki';
$wgWBClientSettings['repoSiteName'] = 'MyWiki';
$wgWBClientSettings['siteLinkGroup'] = 'mywiki';

# Optional
#$wgWBClientSettings['repoNamespaces'] = array(
#	'wikibase-item' => 'Item', //leave empty if items are in the main namespace
#	'wikibase-property' => 'Property'
#);
$wgWBClientSettings['siteGroup'] = 'mywiki'; //you probably don't need this one, but do if your siteGroup is different from 'wikipedia'

# WikimediaBadges Extension
wfLoadExtension( 'WikimediaBadges' );

# WikibaseLexeme Extension
#wfLoadExtension( 'WikibaseLexeme' );

I also noticed that on Wikidata the client is also activated. Did that for my repo too, left $wgEnableWikibaseClient = false; untouched though.

The LocalSettings.php on the repo looks like this:

# Wikibase Extension
$wgEnableWikibaseRepo = true;
$wgEnableWikibaseClient = false;
#$wmgUseWikibaseRepo = true;
#$wmgUseWikibaseClient = false;
#require_once __DIR__ . "/extensions/Wikidata/Wikidata.php";
#require_once __DIR__ . "/extensions/Wikidata/extensions/Wikibase/repo/ExampleSettings.php";
require_once "$IP/extensions/Wikibase/repo/Wikibase.php";
require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";
require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";

$baseNs = 100;

// Define the namespace indexes
define( 'WB_NS_PROPERTY', $baseNs + 2 );
define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );
 
// Define the namespaces
$wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';
$wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';
 
// Assigning the correct content models to the namespaces
#$wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_ITEM] = NS_MAIN; 
$wgWBRepoSettings['entityNamespaces']['item'] = NS_MAIN;

#$wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_PROPERTY] = WB_NS_PROPERTY;
$wgWBRepoSettings['entityNamespaces']['property'] = WB_NS_PROPERTY;

define( 'WB_NS_QUERY', $baseNs + 4 );
define( 'WB_NS_QUERY_TALK', $baseNs + 5 );
 
$wgExtraNamespaces[WB_NS_QUERY] = 'Query';
$wgExtraNamespaces[WB_NS_QUERY_TALK] = 'Query_talk';
 
#$wgWBRepoSettings['entityNamespaces']['CONTENT_MODEL_WIKIBASE_QUERY'] = WB_NS_QUERY;
$wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_QUERY] = WB_NS_QUERY;

$wgWBRepoSettings['changesDatabase'] = 'datawiki';
$wgWBRepoSettings['conceptBaseUri'] = 'https://data.mywiki.com/wiki/';

$wgWBRepoSettings['localClientDatabases'] = array( 'bgwiki', 'bnwiki', 'cswiki', 'dewiki', 'enwiki', 'eswiki', 'frwiki', 'huwiki', 'hywiki', 'itwiki', 'kawiki', 'nlwiki', 'plwiki', 'poolwiki', 'ptwiki', 'pt_brwiki', 'ruwiki', 'srwiki', 'svwiki', 'trwiki' );

# WikimediaBadges Extension
wfLoadExtension( 'WikimediaBadges' );

# WikibaseLexeme Extension
wfLoadExtension( 'WikibaseLexeme' );

I don't really know what to do right now :/ Any help is more than welcome. Thanks and cheers!

Thiemo Kreuz (WMDE) (talkcontribs)
  • Please check if the MediaWiki and Wikibase versions you are using match.
  • WikimediaBadges and WikibaseLexeme are optional. If you are not sure, you probably don't need them.
  • The client's configuration format changed. Even if there is backwards-compatibility code in place, it might have failed for you for some reason. What you can try is to add the new format $wgWBClientSettings['repositories'] = …; either in addition or replacing the old $wgWBClientSettings['repoDatabase']. See WikibaseClient.example.php for an example.
Till Kraemer (talkcontribs)

Hi @Thiemo Kreuz (WMDE), thanks for your suggestions!

I just checked the versions again. I'm running MediaWiki 1.31.0 on the clients and on the repo and the Wikibase version file looks like this:

Wikibase: REL1_31
2018-04-17T22:37:46
8178d16

I added $wgWBClientSettings['repositories'] = 'datawiki'; to LocalSettings.php, but when I run the update script, the following error appears:

[abc123567] [no req]   TypeError from line 117 of /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php: Argument 1 passed to Wikibase\WikibaseSettings::getEntityNamespacesFromRepositorySettings() must be of the type array, string given, called in /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php on line 111
Backtrace:
#0 /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php(111): Wikibase\WikibaseSettings::getEntityNamespacesFromRepositorySettings(string)
#1 /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php(69): Wikibase\WikibaseSettings::buildEntityNamespaceConfigurations(Wikibase\SettingsArray)
#2 /path/to/mywikis/en/w/extensions/Wikibase/client/includes/Hooks/EchoSetupHookHandlers.php(43): Wikibase\WikibaseSettings::getClientSettings()
#3 /path/to/mywikis/en/w/extensions/Wikibase/client/includes/Hooks/EchoSetupHookHandlers.php(65): Wikibase\Client\Hooks\EchoSetupHookHandlers::newFromGlobalState()
#4 /path/to/mywikis/en/w/includes/Hooks.php(177): Wikibase\Client\Hooks\EchoSetupHookHandlers::onBeforeCreateEchoEvent(array, array, array)
#5 /path/to/mywikis/en/w/includes/Hooks.php(205): Hooks::callHook(string, array, array, NULL)
#6 /path/to/mywikis/en/w/extensions/Echo/includes/EchoHooks.php(48): Hooks::run(string, array)
#7 /path/to/mywikis/en/w/includes/Setup.php(940): EchoHooks::initEchoExtension()
#8 /path/to/mywikis/en/w/maintenance/doMaintenance.php(81): require_once(string)
#9 /path/to/mywikis/en/w/maintenance/update.php(245): require_once(string)
#10 {main}

This also happens when I remove $wgWBClientSettings['repoDatabase'] = 'datawiki';. I'm running PHP 7.0.8. Should I upgrade to 7.0.28?

Thanks and cheers!

Thiemo Kreuz (WMDE) (talkcontribs)

The repositories setting is an array, as shown in the example. The empty array key '' might look confusing. This identifies the default repository, which is what you need. All you need to do is to fill in the values for repoDatabase and baseUri, I believe.

Till Kraemer (talkcontribs)

Hi @Thiemo Kreuz (WMDE), thanks for your help!

For some reason, just adding repoDatabase and baseUri doesn't work for me. If I add this to LocalSettings.php...

$wgWBClientSettings['repositories'] = [
			'repoDatabase' => 'datawiki',
			'baseUri' => 'https://data.mywiki.com/entity',
	];

...I get the following error:

[abc1234567] [no req]   TypeError from line 120 of /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php: Argument 2 passed to Wikibase\WikibaseSettings::Wikibase\{closure}() must be of the type array, string given
Backtrace:
#0 [internal function]: Wikibase\WikibaseSettings::Wikibase\{closure}(array, string)
#1 /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php(123): array_reduce(array, Closure, array)
#2 /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php(111): Wikibase\WikibaseSettings::getEntityNamespacesFromRepositorySettings(array)
#3 /path/to/mywikis/en/w/extensions/Wikibase/lib/includes/WikibaseSettings.php(69): Wikibase\WikibaseSettings::buildEntityNamespaceConfigurations(Wikibase\SettingsArray)
#4 /path/to/mywikis/en/w/extensions/Wikibase/client/includes/Hooks/EchoSetupHookHandlers.php(43): Wikibase\WikibaseSettings::getClientSettings()
#5 /path/to/mywikis/en/w/extensions/Wikibase/client/includes/Hooks/EchoSetupHookHandlers.php(65): Wikibase\Client\Hooks\EchoSetupHookHandlers::newFromGlobalState()
#6 /path/to/mywikis/en/w/includes/Hooks.php(177): Wikibase\Client\Hooks\EchoSetupHookHandlers::onBeforeCreateEchoEvent(array, array, array)
#7 /path/to/mywikis/en/w/includes/Hooks.php(205): Hooks::callHook(string, array, array, NULL)
#8 /path/to/mywikis/en/w/extensions/Echo/includes/EchoHooks.php(48): Hooks::run(string, array)
#9 /path/to/mywikis/en/w/includes/Setup.php(940): EchoHooks::initEchoExtension()
#10 /path/to/mywikis/en/w/maintenance/doMaintenance.php(81): require_once(string)
#11 /path/to/mywikis/en/w/maintenance/update.php(245): require_once(string)
#12 {main}

So I added the whole block:

$wgWBClientSettings['repositories'] = [
		'' => [
			'repoDatabase' => 'datawiki',
			'baseUri' => 'https://data.mywiki.com/entity',
			'entityNamespaces' => [
				'item' => WB_REPO_NS_ITEM,
				'property' => WB_REPO_NS_PROPERTY
			],
			'prefixMapping' => [ '' => '' ],
		]
	];

I was now able to run the update script successfully and the item ID links (like https://data.mywiki.com/wiki/Special:EntityPage/Q1234567) show up on the client wiki. However, the interwiki links don't appear on the client wiki and I have the following error in my log file:

PHP Warning:  Wikibase\Client\LangLinkHandler::getEntityLinks: Could not load item Q1234567 for XYZ [Called from Wiki
base\Client\LangLinkHandler::getEntityLinks in /path/to/mywikis/en/w/extensions/Wikibase/client/includes/LangLinkHandler.php at line 116] in /path/to/mywikis/en/w/includes/debug/MWDebug.php on line 309
PHP message: PHP Warning:  According to a SiteLinkLookup Q1234567 is linked to enwiki while it is not or it does not exist. [Called from Wikibase\Client\ParserOutput\ClientParserOutputDataUpdater::setBadgesProperty in /path/to/mywikis/en/w/extensions/Wikibase/client/includes/ParserOutput/ClientParserOutputDa
taUpdater.php at line 139] in /path/to/mywikis/en/w/includes/debug/MWDebug.php on line 309" while reading response header from upstream, client: 1.2.3.4, server: en.mywiki.com, request: "GET /wiki/XYZ HTTP/1.1
", upstream: "fastcgi://1.2.3.4:1234", host: "en.mywiki.com", referrer: "https://en.mywiki.com/wiki/XYZ"

Not sure what I'm missing here :/

Thanks and cheers!

Thiemo Kreuz (WMDE) (talkcontribs)

Oh, I have never seen this message before. It sounds like a secondary database table got out of sync. I'm afraid I need to hand over to the core Wikidata team. Maybe Leszek can help?

PS: I just realized your item namespace is NS_MAIN, not WB_REPO_NS_ITEM. You need to fix this in the configuration you just added.

Till Kraemer (talkcontribs)

Hi @Thiemo Kreuz (WMDE), I changed WB_REPO_NS_ITEM to NS_MAIN in LocalSettings.php as you suggested and woohoo, it works perfectly now! :) Thank you so much for your help! I'm soo happy now! :) Long live Wikibase and Thiemo Kreuz! :)

Cheers!

2601:144:4100:A372:20A1:4DF9:D7DC:A349 (talkcontribs)

I wonder I can run mediaWiki 1.32 without database replication?

Alex Lai

Thiemo Kreuz (WMDE) (talkcontribs)

Hey Alex. Is this question related to Wikibase? If not, I'm afraid this is the wrong page to ask. I'm also not sure if we are talking about the same when we say "database replication". What is the exact issue you run into?

Reply to "Cannot access the database after upgrade to MediaWiki 1.31.0"