claudehohl / Stikked

An advanced and beautiful pastebin written in PHP
991 stars 219 forks source link

SQLite3 - Simultaneous queries: some fail "database is locked" #477

Closed jlpoolen closed 6 years ago

jlpoolen commented 6 years ago

I have an HTML page that contains five iframes pointing to an instance of Stikked using SQLite3. What happens when the page is displayed, some of the iframes error out -- the result is randomly distributed.

The error message is: ` A PHP Error was encountered

Severity: Warning

Message: SQLite3::query(): Unable to execute statement: database is locked

Filename: sqlite3/sqlite3_driver.php

Line Number: 129

Backtrace:

File: [redacted]/Stikked-0.12.0/htdocs/application/controllers/Main.php Line: 98 Function: library

File: [redacted]/Stikked-0.12.0/htdocs/index.php Line: 315 Function: require_once A Database Error Occurred

Error Number: 0

not an error

SELECT "data" FROM "sessions" WHERE "id" = '[REDACTED]'

Filename: libraries/Session/drivers/Session_database_driver.php

Line Number: 169 ` I wonder if SQLite3 has a problem handling almost concurrent connections... I suspect it does. Maybe I should try wrapping the call in a loop which tries several times until a failure no longer occurs?

jlpoolen commented 6 years ago

The work-around for a viewer of the HTML page is to place one's mouse in the frames where the error occurred the then right-click, this frame->refresh.

jlpoolen commented 6 years ago

This is definitely becoming a problem. It looks like the solution may be to migrate to a different database model, i.e. MySQL.

jlpoolen commented 6 years ago

Yes, by migrating to MySQL, the problem of near-simultaneous access has disappeared.

Caution to those using SQLite: if you are going to have a likelihood of multiple access, e.g. a web page with pointing to several pastes, then you may experience an interruption in service on some of the calls.