gpt4 book ai didi

sqlite - 当 MediaWiki 尝试从安装到 docker conainer 的 sqlite db 读取数据时,它会引发 DBTransactionStateError

转载 作者:行者123 更新时间:2023-12-03 02:36:23 25 4
gpt4 key购买 nike

我想在 Docker 容器内运行 MediaWiki。我按照教程here进行操作,使用official mediawiki image 。我想使用 sqlite 而不是 MySQL,以减少单独容器及其文件的麻烦。我已经运行了图像,安装了 wiki 并将数据库和其他目录从容器复制到本地目录:

$ tree -d -L 2
.
└── Social
├── config
├── data
├── extensions
└── images

然后我杀死并删除了 docker 镜像并再次运行它:

docker run --name social-mediawiki -p 8080:80 \
-v ~/Mediawiki/Social/config/LocalSettings.php:/var/www/html/LocalSettings.php \
-v ~/Mediawiki/Social/images:/var/www/html/images \
-v ~/Mediawiki/Social/extensions:/var/www/html/extensions \
-v ~/Mediawiki/Social/data:/var/www/data \
-d mediawiki

不幸的是,它不能像 http://localhost:8080/index.php/Main_Page 那样工作。页面爆炸并出现以下异常

[847547d534f8a6acfbb81a43] /index.php/Main_Page Wikimedia\Rdbms\DBTransactionStateError from line 1312 of /var/www/html/includes/libs/rdbms/database/Database.php: Cannot execute query from MediaWiki\Storage\SqlBlobStore::fetchBlob while transaction status is ERROR.

Backtrace:

#0 /var/www/html/includes/libs/rdbms/database/Database.php(1095): Wikimedia\Rdbms\Database->assertTransactionStatus(string, string)
#1 /var/www/html/includes/libs/rdbms/database/Database.php(1653): Wikimedia\Rdbms\Database->query(string, string)
#2 /var/www/html/includes/libs/rdbms/database/Database.php(1730): Wikimedia\Rdbms\Database->select(string, array, array, string, array, array)
#3 /var/www/html/includes/Storage/SqlBlobStore.php(329): Wikimedia\Rdbms\Database->selectRow(string, array, array, string, array)
#4 /var/www/html/includes/Storage/SqlBlobStore.php(277): MediaWiki\Storage\SqlBlobStore->fetchBlob(string, integer)
#5 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1240): MediaWiki\Storage\SqlBlobStore->MediaWiki\Storage\{closure}(boolean, integer, array, NULL)
#6 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1114): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#7 /var/www/html/includes/Storage/SqlBlobStore.php(279): WANObjectCache->getWithSetCallback(string, integer, Closure, array)
#8 /var/www/html/includes/Storage/RevisionStore.php(921): MediaWiki\Storage\SqlBlobStore->getBlob(string, integer)
#9 /var/www/html/includes/Storage/RevisionStore.php(865): MediaWiki\Storage\RevisionStore->loadSlotContent(MediaWiki\Storage\SlotRecord, NULL, NULL, NULL, integer)
#10 [internal function]: MediaWiki\Storage\RevisionStore->MediaWiki\Storage\{closure}(MediaWiki\Storage\SlotRecord)
#11 /var/www/html/includes/Storage/SlotRecord.php(308): call_user_func(Closure, MediaWiki\Storage\SlotRecord)
#12 /var/www/html/includes/Storage/RevisionRecord.php(173): MediaWiki\Storage\SlotRecord->getContent()
#13 /var/www/html/includes/Revision.php(937): MediaWiki\Storage\RevisionRecord->getContent(string, integer, User)
#14 /var/www/html/includes/page/Article.php(368): Revision->getContent(integer, User)
#15 /var/www/html/includes/page/Article.php(562): Article->fetchContentObject()
#16 /var/www/html/includes/actions/ViewAction.php(68): Article->view()
#17 /var/www/html/includes/MediaWiki.php(500): ViewAction->show()
#18 /var/www/html/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#19 /var/www/html/includes/MediaWiki.php(861): MediaWiki->performRequest()
#20 /var/www/html/includes/MediaWiki.php(524): MediaWiki->main()
#21 /var/www/html/index.php(42): MediaWiki->run()
#22 {main}

Sqlite 文件本身看起来不错:

$ sudo sqlite3 my_wiki.sqlite 
sqlite> PRAGMA integrity_check;
ok
sqlite> select * from page;
1|0|Main_Page||0|1|0.468882297482|20181231020833||1|735|wikitext|
sqlite>

将数据库转储到新文件中(广告描述 here )没有帮助。除调试信息外,LocalSettings.php 未进行任何更改:

$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;

我怎样才能做到这一点?

最佳答案

发现问题了。使用 LocalSettings.php

中的以下设置检查容器中的日志文件后
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;
$wgDebugDumpSql = true;
$wgDebugDBTransactions = true;
$wgDebugLogFile = '/tmp/log';

我发现了很多写访问错误:

[DBQuery] SQL ERROR: attempt to write a readonly database

事实证明,当我挂载sqlite数据库数据时,它设置了以下权限:

# cd /var/www
# ls -l
total 8
drwxr-xr-x 3 root root 4096 Dec 31 03:27 data
drwxrwxrwx 15 www-data www-data 4096 Dec 31 03:30 html

目录的用户和组及其内容也应该是www-data。修复后:

# chown -R www-data:www-data /var/www/data

现在一切都按预期进行。

关于sqlite - 当 MediaWiki 尝试从安装到 docker conainer 的 sqlite db 读取数据时,它会引发 DBTransactionStateError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53983132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com