phpsqlitemediawikilighttpd

Getting database access error after updating arch packages when using mediawiki


I have a server on which I maintain my own wiki using Mediawiki. Until an update two weeks ago, the whole wiki worked perfectly, but since the update I get an error message that the database cannot be accessed. I have set up my wiki with the following components:

according to this manual.

The following updates were made during the update on 05/03/25 (php-cgi & php-sqlite always have the same version number as php):

On 10.05. I carried out another update as part of a troubleshooting process:

The error persisted. After each update of Mediawiki I have performed php maintenance/run.php update. After activating the corresponding flag in LocalSettings.php I get the following error message:

MediaWiki internal error.

Original exception: [b923ab9115bdc4186a4ba4d9] /mediawiki/index.php?title=Hauptseite Wikimedia\Rdbms\DBConnectionError: Cannot access the database: Error 14: unable to open database file
Function: Wikimedia\Rdbms\DatabaseSqlite::open
Query: PRAGMA synchronous = NORMAL

Backtrace:
from /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(1221)
#0 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseSqlite.php(230): Wikimedia\Rdbms\Database->newExceptionAfterConnectError()
#1 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(263): Wikimedia\Rdbms\DatabaseSqlite->open()
#2 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseFactory.php(157): Wikimedia\Rdbms\Database->initConnection()
#3 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(143): Wikimedia\Rdbms\DatabaseFactory->create()
#4 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(56): LCStoreDB->getWriteConnection()
#5 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(566): LCStoreDB->get()
#6 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(612): LocalisationCache->isExpired()
#7 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(479): LocalisationCache->initLanguage()
#8 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(381): LocalisationCache->loadItem()
#9 /usr/share/webapps/mediawiki/includes/language/Language.php(567): LocalisationCache->getItem()
#10 /usr/share/webapps/mediawiki/includes/title/MediaWikiTitleCodec.php(120): MediaWiki\Language\Language->needsGenderDistinction()
#11 /usr/share/webapps/mediawiki/includes/title/Title.php(1157): MediaWiki\Title\MediaWikiTitleCodec->getNamespaceName()
#12 /usr/share/webapps/mediawiki/includes/page/Article.php(494): MediaWiki\Title\Title->getNsText()
#13 /usr/share/webapps/mediawiki/includes/actions/ViewAction.php(78): Article->view()
#14 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(733): ViewAction->show()
#15 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(510): MediaWiki\Actions\ActionEntryPoint->performAction()
#16 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(146): MediaWiki\Actions\ActionEntryPoint->performRequest()
#17 /usr/share/webapps/mediawiki/includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()
#18 /usr/share/webapps/mediawiki/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#19 {main}

Exception caught inside exception handler: [b923ab9115bdc4186a4ba4d9] /mediawiki/index.php?title=Hauptseite Wikimedia\Rdbms\DBConnectionError: Cannot access the database: Error 14: unable to open database file
Function: Wikimedia\Rdbms\DatabaseSqlite::open
Query: PRAGMA synchronous = NORMAL

Backtrace:
from /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(1221)
#0 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseSqlite.php(230): Wikimedia\Rdbms\Database->newExceptionAfterConnectError()
#1 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(263): Wikimedia\Rdbms\DatabaseSqlite->open()
#2 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseFactory.php(157): Wikimedia\Rdbms\Database->initConnection()
#3 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(143): Wikimedia\Rdbms\DatabaseFactory->create()
#4 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(56): LCStoreDB->getWriteConnection()
#5 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(539): LCStoreDB->get()
#6 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(403): LocalisationCache->loadSubitem()
#7 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(419): LocalisationCache->getSubitem()
#8 /usr/share/webapps/mediawiki/includes/language/MessageCache.php(1267): LocalisationCache->getSubitemWithSource()
#9 /usr/share/webapps/mediawiki/includes/language/MessageCache.php(1209): MessageCache->getMessageForLang()
#10 /usr/share/webapps/mediawiki/includes/language/MessageCache.php(1103): MessageCache->getMessageFromFallbackChain()
#11 /usr/share/webapps/mediawiki/includes/Message/Message.php(1554): MessageCache->get()
#12 /usr/share/webapps/mediawiki/includes/Message/Message.php(1036): MediaWiki\Message\Message->fetchMessage()
#13 /usr/share/webapps/mediawiki/includes/Message/Message.php(1127): MediaWiki\Message\Message->format()
#14 /usr/share/webapps/mediawiki/includes/exception/MWExceptionRenderer.php(253): MediaWiki\Message\Message->text()
#15 /usr/share/webapps/mediawiki/includes/exception/MWExceptionRenderer.php(399): MWExceptionRenderer::msg()
#16 /usr/share/webapps/mediawiki/includes/exception/MWExceptionRenderer.php(107): MWExceptionRenderer::reportOutageHTML()
#17 /usr/share/webapps/mediawiki/includes/exception/MWExceptionHandler.php(135): MWExceptionRenderer::output()
#18 /usr/share/webapps/mediawiki/includes/exception/MWExceptionHandler.php(239): MWExceptionHandler::report()
#19 /usr/share/webapps/mediawiki/includes/MediaWikiEntryPoint.php(222): MWExceptionHandler::handleException()
#20 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(82): MediaWiki\MediaWikiEntryPoint->handleTopLevelError()
#21 /usr/share/webapps/mediawiki/includes/MediaWikiEntryPoint.php(206): MediaWiki\Actions\ActionEntryPoint->handleTopLevelError()
#22 /usr/share/webapps/mediawiki/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#23 {main}

Opening the database as http user shows, that the database exists and is readable and writeable by http user

$ sudo setpriv --reuid http --regid http --clear-groups sqlite3 /usr/share/webapps/data/bp_wiki.sqlite
sqlite> .database
main: /usr/share/webapps/data/bp_wiki.sqlite r/w

So I do not understand, why I get this error. Is php not able to access the database? Is the problem cause by sqlite?

Another thing I observed is, that when removing the associated LocalSettings.php and call the url of the wiki, I expectably get the message that there is no configuration and that I can set up a new wiki. When trying to do this, I get an error message, that there is no valid session sess_xyz file in /var/lib/php/senssions. Taking a look into this folder shows one session file but with an other file name.

What could be the reason? Why doesn't php create a new session? I also checked the permissions. All paths mentioned in the manual are accessible by http user running the lighttpd webserver.

I hope it is possible to understand my question even if English isn't my native language.

[EDIT]

as @gstrauss suggested, the changes in lighttpd to hardening the system were the cause. The key ProtectSystem=full in the service prohibits the webserver from writing to directories under /usr, but this is, where my databse resides. So I had to allow lighttpd accessing this directory by $ systemctl edit lighttpd to create /etc/systemd/system/lighttpd.service.d/override.conf and adding

[Service]
ReadWritePaths=/usr/share/webapps/data

to this file. After

$ systemctl reenable lighttpd
$ systemctl reload lighttpd
$ systemctl daemon-reload

the database was accessible again.


Solution

  • Originally https://bbs.archlinux.org/viewtopic.php?pid=2242464

    Repeating answer from https://bbs.archlinux.org/viewtopic.php?pid=2242464#p2242464 :

    lighttpd 1.4.79 hardened the systemd lighttpd.service, and that lighttpd.service is install by Arch Linux https://gitlab.archlinux.org/archlinux/packaging/packages/lighttpd/-/blob/main/PKGBUILD?ref_type=heads#L87

    The lighttpd 1.4.79 release notes highlighted this in BEHAVIOR CHANGES: see https://redmine.lighttpd.net/projects/lighttpd/wiki/Release-1_4_79

    See the "# systems capability hardening" section in https://git.lighttpd.net/lighttpd/lighttpd1.4/src/branch/master/doc/systemd/lighttpd.service#L29

    Please post which of those setting is causing trouble for your setup and let us submit some updated instructions to MediaWiki install docs.