-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database lock error by frequent operation of sqlite-related plugins #83
Comments
Some observations:
|
Hello @splitbrain, Sorry for not providing the necessary information in the post. I'll add them up here.
I don't know why the RAM is restricted on the server, I tried to extend the RAM in the PHP config file, but it didn't solve the problem.
My database is locked now so I cannot check the dbversion; this situation often happened recently, my only solution is to download and delete the .db file under the meta folder, then dump it as sql file and import it again; and after several days the database is locked again. From the file I have downloaded from the meta folder, the dbversion is 19.
The SQLite version is 3.39.4 via
it's max_execution_time. It was 120s before, I have changed it to 300s.
yes, please refer to https://demodb.org/struct_demodbtest.tar.gz |
version 19 is the most recent struct db. I think the migration is run because if we encounter an error in reading the DB version, we log an error but still try to create the opts table and return version 0. This obviously makes no sense. I guess we need to throw an exception there? Lines 462 to 475 in 6cb8d74
Of course this does not explain the actual problem causing the database lock... @annda can you look into this and see if you can reproduce the problem? |
Update: I have also tried to check the dbversion of struct database directly from the interface provided by SQLite plugin, but get a |
Hello @splitbrain , Today I recovered my struct database and open the debug log in the admin panel. I notice that the struct is keeping execute some queries while I don't know what are they for. My virtual server's IO has been restricted to 2MB/s and seems the queries are always eat all IO up so the server runs slowly. Is it a potential cause of the problem? Followings are pieces of the selected log:
|
Thanks for all the additional info. But even with your database, I could not reproduce any of the problems on a local machine. Of course it has more resources than your hosted machine, but still the queries should not be slow. Around 4 seconds is excessive. There is also the first error you report in io.php. The code causing problems deletes directories recursively, which has nothing to do with the database. I suspect that your disk is (very) slow and some processes get terminated before completion. If this happens during database operations, it is only natural that the database remains locked, because the process was killed that would unlock the database. In that case we cannot do anything. Can you find out more about the physical disk storage and the I/O limit? How is it measured and set? Which processes are killed when the limit is reached? |
Hello Annda and thank you for your reply. I'm now still checking this problem and seems I have partially found how it was triggered:
My dokuwiki is running on a virtual host, and all operations are done via cpanel. Here are the resource limits of my host:
I just checked the whole host for the problem and found that there is a huge log file on the server connection. I've downloaded the file and found that a struct filter/aggregation page (https://demodb.org/songs/sort\\\_by, remove the '\') was requested frequently by numerous clients. They seem to find all options, and try to request all of them one by one -- I tried to block the URL that they are requesting, and it didn't take a long time, the I/O Usage has decreased significantly, and when I recover the page, the IO increased right away, which means those requests are flooding my host. I think this explains why my server was slow as a turtle every time I enabled the struct. I have added the Disallow line in robots.txt, trying to make spiders stop crawling on this page. I guess maybe struct needs a captcha feature to protect the filter/aggregation page from being flooding. The request flooding my site is like this:
And there's another thing I noticed for the database lock: I suspected the changes in table structure might be one of the conditions. After the main update of SQLite in July, the struct plugin on my site seems not working very smoothly -- my database failed to query at first, then the dbversion often changes to 0, luckily those problems are solved in the following updates. I guess my database was not 'upgraded' properly with the plugin, and I have checked my struct database table by table and found that there is a 'chksum' column in the schemas table, but in my original database, it does not exist. So I tried to delete the struct.sqlite3 in the meta folder, rebuild the database using the SQL file dumped from the latest file, and INSERT the items one by one. After I've done this, the DokuWiki seems to be working fine, and the database is not locked so far (for 24 hours) even the spiders are flooding my aggregation page. But there is still a thing that confuses me, I think there should be no writing action when the filter/aggregation page is being flooded, so theoretically numerous requests on the filter/aggregation page should only make the site slow response, it shouldn't end up in a locked database. I don't know if there any high-load action in the struct's design would cause that. However the problem seems to be solved temporarily, I'll keep tracking this issue on my site, and report it to you if it occurs again. Thank you for your attention! |
Hello,
I have updated the SQLite and struct, ratings plugins to the latest version, but these days "database locked" error often occurs and it makes the DokuWiki fail to function.
The error seems to happen in the following processes, based on the error log of DokuWiki:
First, the DokuWiki exceeds the IO limited by the server:
2023-12-09 07:48:07 /path_doku/inc/io.php(538) E_ERROR: Allowed memory size of 67108864 bytes exhausted (tried to allocate 16777224 bytes)
then, the SQLite seems to try to be in WAL mode but failed:
then, the database is locked:
and more error:
When the error occurs, at first, the whole page of the site (like the index) cannot be rendered properly, it will stop the rendering at the sidebar and show the error message on the position where the sidebar should be; if one refresh the page several times, the page will be broken and only a error information with the hint saying the sqlite might have problems:
I suspected the issue was caused by ratings plugins as the plugins is not updated for years. but after disabling it, the SQLite didn't work again and this time it was caused by struct. the strange thing is that we have not updated the struct data for a long time (just look up, no write or update), I have no idea what kind of operation caused the database lock.
I think this error is also related to a limited RAM assigned to a single php thread and a limited time of execution. Is there any possible solution for it? Thanks!
The text was updated successfully, but these errors were encountered: