1、标题:启用选题测试,保存成功。网络响应:error_code 的值为 0。如图1
2、返回文档页面,标题:启用选题,添加的测试两字未显示。即保存成功后,文档无变化。如图2
3、查看历史版本,也无刚才的修改记录。如图3
4、新建接口文档,保存时,响应失败:{“error_code”:10103,”error_message”:”request fail”}。如图4
{ "error_code": 10103, "error_message": "request fail" }
5、ShowDoc 是基于 ThinkPHP 框架编写。查看运行时日志文件,/Application/Runtime/Logs/Api/20_09_11.log。报错:ERR: 11:database disk image is malformed。如图5
[ 2020-09-11T13:09:52+08:00 ] 10.42.1.14 /server/index.php?s=/api/page/save ERR: 11:database disk image is malformed [ SQL语句 ] : INSERT INTO page (page_title,page_content,page_comments,item_id,cat_id,addtime,author_uid,author_username) VALUES ('222','欢迎使用ShowDoc!','','67','669','1599800992','96','wangqiang@chinamcloud.com') [ 2020-09-11T13:10:53+08:00 ] 10.42.1.14 /server/index.php?s=/api/page/save ERR: 11:database disk image is malformed [ SQL语句 ] : INSERT INTO page (page_title,page_content,page_comments,item_id,cat_id,addtime,author_uid,author_username) VALUES ('222','欢迎使用ShowDoc!','','67','669','1599801053','96','wangqiang@chinamcloud.com')
6、将 showdoc.db.php 移动至 showdoc.db.php_mv_0911bak。将 showdoc.db.php_0820bak 复制至 showdoc.db.php。如图6
bash-4.4# mv showdoc.db.php showdoc.db.php_mv_0911bak bash-4.4# ls showdoc.db.php.bak showdoc.db.php_0311bak showdoc.db.php_0820bak showdoc.db.php_0911bak showdoc.db.php_mv_0911bak bash-4.4# ls -l total 200860 -rwxrwxrwx 1 nobody nobody 24115200 Aug 21 16:48 showdoc.db.php.bak -rwxrwxrwx 1 nobody nobody 24398848 Aug 21 16:48 showdoc.db.php_0311bak -rwxrwxrwx 1 nobody nobody 50750464 Aug 21 16:48 showdoc.db.php_0820bak -rwxr-xr-x 1 nobody nobody 53199872 Sep 11 05:27 showdoc.db.php_0911bak -rwxrwxrwx 1 nobody nobody 53199872 Sep 11 05:16 showdoc.db.php_mv_0911bak bash-4.4# cp showdoc.db.php_0820bak showdoc.db.php bash-4.4# ls -l total 265372 -rwxr-xr-x 1 nobody nobody 50750464 Sep 11 05:34 showdoc.db.php -rwxrwxrwx 1 nobody nobody 24115200 Aug 21 16:48 showdoc.db.php.bak -rwxrwxrwx 1 nobody nobody 24398848 Aug 21 16:48 showdoc.db.php_0311bak -rwxrwxrwx 1 nobody nobody 50750464 Aug 21 16:48 showdoc.db.php_0820bak -rwxr-xr-x 1 nobody nobody 53199872 Sep 11 05:27 showdoc.db.php_0911bak -rwxrwxrwx 1 nobody nobody 53199872 Sep 11 05:16 showdoc.db.php_mv_0911bak bash-4.4#
7、新建接口文档,保存成功,未再报错,而且返回文档页面,文档新建成功。如图7
8、编辑接口文档,保存成功,而且返回文档页面,文档有变化。如图8
9、因此,可以确定,Sqlite 文件存在问题。有待于分析修复。在 Google 中搜索:sqlite repair。打开第一个网址:https://www.recoveryandmanagement.com/repair-sqlite-database-manually/ 。手动修复 SQLite 数据库。从损坏的数据库中恢复 SQLite 数据。
10、在此处使用一个简单的手动技巧来修复 SQLite 数据库。下载:SysInfoTools-SQLite-Database-Recovery.exe。安装后,打开数据库文件:showdoc.db.php。如图9
11、打开表:page 时,报错:Corruption in file Cell content area。打开表皆未报错。如图10
12、由于是演示版本,无法基于此软件进行修复工作。参考网址:https://stackoverflow.com/questions/18259692/how-to-recover-a-corrupt-sqlite3-database/18260642 。
PS E:/Develop/2020> sqlite3 showdoc.db.php "PRAGMA integrity_check" *** in database main *** Main freelist: 3 of 3 pages missing from overflow list starting at 0 Page 34 is never used Page 35 is never used Page 36 is never used Page 95 is never used
13、使用 .dump 转储整个数据库并使用这些命令来创建新数据库来获取部分或大部分记录。生成的文件:showdoc.db.php_repair 。其大小为 0 KB。如图11
PS E:/Develop/2020> sqlite3 showdoc.db.php ".dump" | sqlite3 showdoc_repair.db
14、参考网址:https://blog.csdn.net/sangyongjia/article/details/54910104 。可以尝试通过简单的导出导入方式对损坏的库文件作修复。如图12
PS E:/Develop/2020> sqlite3 showdoc.db.php SQLite version 3.7.17 2013-05-20 00:56:22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .output "tmp.sql" sqlite> .dump sqlite> .quit PS E:/Develop/2020> sqlite3 new.sqlite3 SQLite version 3.7.17 2013-05-20 00:56:22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .read "tmp.sql" sqlite> .quit
15、最后生成文件:tmp.sql、new.sqlite3。将 new.sqlite3 重命名为 showdoc.db.php。覆盖至服务器中。如图13
PS E:/Develop/2020> sqlite3 new.sqlite3 "PRAGMA integrity_check" ok PS E:/Develop/2020> sqlite3 showdoc.db.php "PRAGMA integrity_check" ok
16、容器重新部署后,保存成功,文档有变化。符合预期。如图14
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/181580.html