Page MenuHomePhabricator

Command-line maintenance/parse.php tool is broken by localization
Open, Needs TriagePublic

Description

cananian@skiffserv:~/Projects/Wikimedia/core$ echo hi | php5 maintenance/parse.php 
parse.php: warning: reading wikitext from STDIN. Press CTRL+D to parse.

PHP Warning:  rename(/tmp/l10n_cache-en.cdb.tmp.716440607,/tmp/l10n_cache-en.cdb): Operation not permitted in /home/cananian/Projects/Wikimedia/core/vendor/wikimedia/cdb/src/Writer/DBA.php on line 59
[28f21f9806237faa204e3850] [no req]   MWException from line 118 of /home/cananian/Projects/Wikimedia/core/includes/cache/localisation/LCStoreCDB.php: Unable to move the new CDB file into place.
Backtrace:
#0 /home/cananian/Projects/Wikimedia/core/includes/cache/localisation/LocalisationCache.php(1024): LCStoreCDB->finishWrite()
#1 /home/cananian/Projects/Wikimedia/core/includes/cache/localisation/LocalisationCache.php(462): LocalisationCache->recache(string)
#2 /home/cananian/Projects/Wikimedia/core/includes/cache/localisation/LocalisationCache.php(336): LocalisationCache->initLanguage(string)
#3 /home/cananian/Projects/Wikimedia/core/includes/cache/localisation/LocalisationCache.php(273): LocalisationCache->loadItem(string, string)
#4 /home/cananian/Projects/Wikimedia/core/languages/Language.php(466): LocalisationCache->getItem(string, string)
#5 /home/cananian/Projects/Wikimedia/core/includes/search/SearchEngine.php(400): Language->getNamespaces()
#6 /home/cananian/Projects/Wikimedia/core/includes/user/User.php(1537): SearchEngine::searchableNamespaces()
#7 /home/cananian/Projects/Wikimedia/core/includes/user/User.php(5150): User::getDefaultOptions()
#8 /home/cananian/Projects/Wikimedia/core/includes/user/User.php(2769): User->loadOptions()
#9 /home/cananian/Projects/Wikimedia/core/includes/context/RequestContext.php(369): User->getOption(string)
#10 /home/cananian/Projects/Wikimedia/core/includes/StubObject.php(197): RequestContext->getLanguage()
#11 /home/cananian/Projects/Wikimedia/core/includes/StubObject.php(159): StubUserLang->_newObject()
#12 /home/cananian/Projects/Wikimedia/core/includes/parser/ParserOptions.php(595): StubObject->_unstub()
#13 /home/cananian/Projects/Wikimedia/core/maintenance/parse.php(133): ParserOptions->__construct()
#14 /home/cananian/Projects/Wikimedia/core/maintenance/parse.php(84): CLIParser->parse(string)
#15 /home/cananian/Projects/Wikimedia/core/maintenance/parse.php(76): CLIParser->render(string)
#16 /home/cananian/Projects/Wikimedia/core/maintenance/doMaintenance.php(103): CLIParser->execute()
#17 /home/cananian/Projects/Wikimedia/core/maintenance/parse.php(139): require_once(string)
#18 {main}
PHP Warning:  dba_close(): 204 is not a valid DBA identifier resource in /home/cananian/Projects/Wikimedia/core/vendor/wikimedia/cdb/src/Writer/DBA.php on line 54
PHP Warning:  rename(/tmp/l10n_cache-en.cdb.tmp.716440607,/tmp/l10n_cache-en.cdb): Operation not permitted in /home/cananian/Projects/Wikimedia/core/vendor/wikimedia/cdb/src/Writer/DBA.php on line 59
PHP Fatal error:  Uncaught exception 'Cdb\Exception' with message 'Unable to move the new CDB file into place.' in /home/cananian/Projects/Wikimedia/core/vendor/wikimedia/cdb/src/Writer/DBA.php:60
Stack trace:
#0 /home/cananian/Projects/Wikimedia/core/vendor/wikimedia/cdb/src/Writer.php(88): Cdb\Writer\DBA->close()
#1 [internal function]: Cdb\Writer->__destruct()
#2 {main}
  thrown in /home/cananian/Projects/Wikimedia/core/vendor/wikimedia/cdb/src/Writer/DBA.php on line 60
cananian@skiffserv:~/Projects/Wikimedia/core$

git-bisect reports that the guilty commit is:

36171312ef0e1b9acdea876f300dca8f3ad9982e is the first bad commit
commit 36171312ef0e1b9acdea876f300dca8f3ad9982e
Author: Ori Livneh <ori@wikimedia.org>
Date:   Thu Nov 5 17:27:47 2015 -0800

    LocalisationCache: try harder to use LCStoreCDB
    
    When the LocalisationCache class is set to 'detect', we prefer LCStoreCDB if
    $wgCacheDirectory is set, but we default to LCStoreDB otherwise. Rather than
    give up, we should try wfTempDir(), since any directory that meets its criteria
    is also suitable for LCStoreCDB.
    
    Change-Id: Id3e2d2b18ddb423647bf2e893bcf942722c0e097

:040000 040000 8f365c359fc535a36be5a49c0bf9648d22a0ba16 dfbc93d5a86b709c45cf3538d840ff7b4e85fc56 M	includes

Event Timeline

cscott updated the task description. (Show Details)
cscott added a subscriber: ori.

It appears that wfTempDir() is not entirely appropriate for LCStoreCDB?

Setting

$wgLocalisationCacheConf['store'] = 'db';

in my LocalSettings.php worked around the issue.

Looking at my /tmp directory I see:

-rw-r--r-- 1 www-data www-data 1071913 Apr 11 13:16 /tmp/l10n_cache-en.cdb
-rw-r--r-- 1 cananian cananian 1039818 Apr 11 14:52 /tmp/l10n_cache-en.cdb.tmp.141762011
-rw-r--r-- 1 cananian cananian  954784 Apr 11 15:02 /tmp/l10n_cache-en.cdb.tmp.1428935410

(and lots more tmp files)

It appears as if the assumption that we can use /tmp for CDB storage is not true when there are more than one mediawiki instance on the machine, since the cache filename is not suffixed by a wiki-specific identifier. (CLI tools are a special case, appearing as a second wiki instance in this case).