PHP Warning: SQLite3::query()

I'm just curious if anyone checks their server logs and maybe getting these warnings. These will not show up in the CSC logs more than likely because they are just warnings and not errors.



My sites function just fine and I am not that concerned with the warnings but I am just trying to figure out if they are because I have cache disabled or not. I get so many of them that I am considering turning error logging off.


PHP Warning: SQLite3::query() [sqlite3.query]: disk I/O error in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 40
PHP Warning: SQLite3::query() [sqlite3.query]: disk I/O error in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 93
PHP Warning: SQLite3::query() [sqlite3.query]: disk I/O error in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 85
PHP Warning: SQLite3::query() [sqlite3.query]: database is locked in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 85

[quote name='The Tool' timestamp='1333579303' post='134330']

I'm just curious if anyone checks their server logs and maybe getting these warnings. These will not show up in the CSC logs more than likely because they are just warnings and not errors.



My sites function just fine and I am not that concerned with the warnings but I am just trying to figure out if they are because I have cache disabled or not. I get so many of them that I am considering turning error logging off.


PHP Warning: SQLite3::query() [sqlite3.query]: disk I/O error in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 40
PHP Warning: SQLite3::query() [sqlite3.query]: disk I/O error in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 93
PHP Warning: SQLite3::query() [sqlite3.query]: disk I/O error in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 85
PHP Warning: SQLite3::query() [sqlite3.query]: database is locked in /home/user/public_html/core/cache/class.cache_backend_sqlite.php on line 85


[/quote]



Yes and Yes Tool



Not sure if you are running 2.2.4, however, after I upgraded to this version we have experienced the same although only if SQLITE is selected as the cache method, I am convinced that something in the 2.2.4 release has broken only the sqlite cache method.



You mention having the cache disabled, although I am curious as to what value (if any) you have entered as your cache choice in config.local.php?



I ended up having to switch back to the Files cache method for the time being to stop our error log from blowing up as you mentioned.

As you well know Struck, I haven't been using cache for quite some time now. I am upgraded to 2.2.4 and I do have sqlite selected for cache. Now disabling cache doesn't mean that it completely disables cache. It does cache very little hence the reason for the warning messages but it is good to know it is not because I have disabled it.



I have looked at class.cache_backend_sqlite.php and did a little research and the only thing that I could find was in the php manual. Someone added a note in the manual stating:

[quote]If you get the error message saying “SQLite3::exec. database locked.” You just need to define a busyTimeout to work around this.[/quote]



Maybe zeke needs to re-look this over and make some adjustments? Hopefully he will see this but I haven't seen him around in awhile.

[size=“3”][quote]As you well know Struck, I haven’t been using cache for quite some time now. I am upgraded to 2.2.4 and I do have sqlite selected for cache. Now disabling cache doesn’t mean that it completely disables cache. It does cache very little hence the reason for the warning messages but it is good to know it is not because I have disabled it.[/size][/quote]



I remembered Tool, guess I was curious as to, since you are only minimally using the built-in cache, if you tried selecting a different cache method in your config.local.php? I believe this will at least fix the exploding error log file issue until CS-Cart finds & fixs the SQLITE issue (Database Locked) in the 2.2.4 release. ;-)

Yep, I reckon that's another option.

Hello.



May be this fix will help you.



In file core/cache/class.cache_backend_sqlite.php

after line

113 self::$db = self::_db_init();

add

self::_set_timeout(60000);



in the end of the file please add the next function

```php

/**

  • Sets timeout for waiting if SQLite database is busy.
  • @param int $msec Timeout in milliseconds
  • @return boolean

    */

    function _set_timeout($msec)

    {

    $result = false;



    if ((self::$db_class == 'SQLite3' || self::$db_class == 'SQLiteDatabase') && method_exists(self::$db, 'busyTimeout')) {

    $result = self::$db->busyTimeout($msec);

    } elseif (self::$db_class == 'PDO') {

    $result = self::$db->setAttribute(PDO::ATTR_TIMEOUT, ($msec / 1000));

    }



    return $result;

    }

    ```



    Also you can try to increase the timeout value.

Hmm… I thought this had fixed my problems with errors appearing in cs-carts error log, and sometimes even in admin and front, but unfortunately not.



I'm getting the following errors when using sqlite… could this be related?





[31-May-2012 10:03:09 UTC] PHP Warning: SQLite3::query() [sqlite3.query]: Unable to execute statement: database is locked in /home/MYSITE/public_html/core/cache/class.cache_backend_sqlite.php on line 129
[31-May-2012 10:03:09 UTC] PHP Warning: SQLite3::query() [sqlite3.query]: database is locked in /home/MYSITE/public_html/core/cache/class.cache_backend_sqlite.php on line 93
[31-May-2012 10:03:09 UTC] PHP Warning: SQLite3::query() [sqlite3.query]: database is locked in /home/MYSITE/public_html/core/cache/class.cache_backend_sqlite.php on line 85
[31-May-2012 10:03:10 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/MYSITE/public_html/core/cache/class.cache_backend_sqlite.php:129) in /home/MYSITE/public_html/lib/captcha/captcha.php on line 345

Unfortunately, this fix is not a panacea, this is a feature of SQLite.



You can skip error logging by adding the '@' symbol before each 'self::$db->query' statement, e.g.



@self::$db->query("REPLACE ...");

Adding the timeout actually renders the site useless. The only thing that shows is the following error when loading the site.


[b]Fatal error[/b]: Call to undefined method Cache_backend_sqlite::_set_timeout() in [b]/home/user/public_html/core/cache/class.cache_backend_sqlite.php[/b] on line [b]114[/b]



Edit: Well it looks like I misplaced the code. Testing now and will post results.

/**
* Sets timeout for waiting if SQLite database is busy.
* @param int $msec Timeout in milliseconds
* @return boolean
*/
function _set_timeout($msec)
{
$result = false;

if ((self::$db_class == 'SQLite3' || self::$db_class == 'SQLiteDatabase') && method_exists(self::$db, 'busyTimeout')) {
$result = self::$db->busyTimeout($msec);
} elseif (self::$db_class == 'PDO') {
$result = self::$db->setAttribute(PDO::ATTR_TIMEOUT, ($msec / 1000));
}

return $result;
}
}

?>

[quote name='2tl' timestamp='1338534622' post='137812']

Unfortunately, this fix is not a panacea, this is a feature of SQLite.



You can skip error logging by adding the '@' symbol before each 'self::$db->query' statement, e.g.



@self::$db->query("REPLACE ...");


[/quote]



But do you have any idea why me and some other people are getting these errors? Also see [url=“Need help.. Moved to new Server.. - Configuration - CS-Cart Community Forums”]Need help.. Moved to new Server.. - Configuration - CS-Cart Community Forums

Update: So far I have not received any SQLite warnings.

I am getting the following errors on two v2.2.4 sites both on the same dedicated server. One site seems to get them much more often (several times per day) and the other not so often, but still not ideal.



[b]Warning[/b]: SQLite3::query() [[url="http://www.domain.com/sqlite3.query"]sqlite3.query[/url]]: database is locked in [b]/home/myusername/public_html/core/cache/class.cache_backend_sqlite.php[/b] on line [b]40[/b]

[b]Warning[/b]: Cannot modify header information - headers already sent by (output started at /home/myusername/public_html/core/cache/class.cache_backend_sqlite.php:40) in [b]/home/myusername/public_html/core/fn.init.php[/b] on line [b]412[/b]

[b]Warning[/b]: SQLite3::query() [[url="http://www.domain.com/sqlite3.query"]sqlite3.query[/url]]: Unable to execute statement: database is locked in [b]/home/myusername/public_html/core/cache/class.cache_backend_sqlite.php[/b] on line [b]129[/b]

Warning: Cannot modify header information - headers already sent by (output started at /home/myusername/public_html/core/cache/class.cache_backend_sqlite.php:40) in /home/myusername/public_html/core/fn.common.php on line 1821




Any ideas? No point caching via file as it's too slow and defeats the purpose using mysql caching.

Did you implement the timout code above? I haven't had any warnings since I did.

[quote name='StellarBytes' timestamp='1339183530' post='138338']

I am getting the following errors on two v2.2.4 sites both on the same dedicated server. One site seems to get them much more often (several times per day) and the other not so often, but still not ideal.



[b]Warning[/b]: SQLite3::query() [[url="http://www.domain.com/sqlite3.query"]sqlite3.query[/url]]: database is locked in [b]/home/myusername/public_html/core/cache/class.cache_backend_sqlite.php[/b] on line [b]40[/b]

[b]Warning[/b]: Cannot modify header information - headers already sent by (output started at /home/myusername/public_html/core/cache/class.cache_backend_sqlite.php:40) in [b]/home/myusername/public_html/core/fn.init.php[/b] on line [b]412[/b]

[b]Warning[/b]: SQLite3::query() [[url="http://www.domain.com/sqlite3.query"]sqlite3.query[/url]]: Unable to execute statement: database is locked in [b]/home/myusername/public_html/core/cache/class.cache_backend_sqlite.php[/b] on line [b]129[/b]

Warning: Cannot modify header information - headers already sent by (output started at /home/myusername/public_html/core/cache/class.cache_backend_sqlite.php:40) in /home/myusername/public_html/core/fn.common.php on line 1821




Any ideas? No point caching via file as it's too slow and defeats the purpose using mysql caching.

[/quote]



Are you seeing this in cs-carts error_log and on customer and admin site during normal use? Then it's something else and this fix won't help you (even though you should apply it)



Did you just move servers? If so try deleting your var/cache and car/compiled folders all together. If after a while errors come back, your server should be reconfigured.

[quote name='The Tool' timestamp='1339191316' post='138341']

Did you implement the timout code above? I haven't had any warnings since I did.

[/quote]

Yes I did once I found this post and I still got them for a couple of hours afterwards despite deleting /var/cache/ and /var/compiled/ - however, as for today, so far, so good. Maybe the full server reboot I did last night has helped matters?

[quote name='Flow' timestamp='1339220206' post='138357']

Are you seeing this in cs-carts error_log and on customer and admin site during normal use? Then it's something else and this fix won't help you (even though you should apply it)



Did you just move servers? If so try deleting your var/cache and car/compiled folders all together. If after a while errors come back, your server should be reconfigured.

[/quote]

I am getting the errors showing both on the back-end and on the front-end during normal use, I can be viewing the page, go away from my laptop, come back, refresh the page and it's covered in these errors again. I stripped my errors down - the same 4 I posted earlier are duplicated and displayed 2-3 times.



I did all the updates to the stable release versions last night in WHM, hopefully something has fixed itself in doing this as so far so good this morning - time will tell!



Thanks guys.

I had exactly the same as you. 5 tech support people couldn't figure out what it was… in the end Jesse Lee Stringer fixed it for me (and also hardened and tweaked my new server).



It had something to do with permissions of the sqlite folder or something like that.

Thanks Flow - will get in touch with Jesse and see what can be done as I am moving all clients across to CS-Cart at the moment, so both these dedicated servers will only be running CS-Cart sites so makes sense to fully optimise them for CS-Cart performance.