Yii Cache:在SQLite中发生SQLite DB Lock数据库锁定异常

Yii Cache工作正常,直到今天我在使用缓存的脚本中看到数据库异常:</ p>

 异常'CDbException',消息'CDbCommand无法执行SQL语句:SQLSTATE [HY000]:一般错误:5数据库被锁定。 执行的SQL语句是:DELETE FROM YiiCache WHERE id ='9ccac723c84ae75582784f9e3738d781''在C:\ xampp \ htdocs \ framework \ db \ CDbCommand.php:336 
</ code> </ pre>

我不知道为什么在一分钟之前一切正常的时候出现了这个错误。 之后,我看到了几个相同的异常Yii缓存,然后是另一个:</ p>

 异常'CDbException',消息'CDbCommand无法执行SQL语句:CDbCommand无法准备SQL 声明:SQLSTATE [HY000]:常规错误:1表YiiCache已存在。 执行的SQL语句是:CREATE TABLE YiiCache 

expire INTEGER,
)'在C:\ xampp \ htdocs \ framework \ db \ CDbCommand.php中 :336
</ code> </ pre>

由于缓存正在代码中的许多地方使用,所以我不能把try catch放到任何地方,而是我想解决根本原因。 当我删除db缓存文件并且框架启动了一个新文件时,这个问题就解决了。 旧文件大小约为71MB。</ p>

环境:</ p>

WAMP </ p>

Yii框架:1.1.8 </ p>

PHP版本:5.3.8 </ p>

请告诉我,以便将来可以避免这种情况。</ p>

谢谢</ p>

更新:</ strong> </ p>

我想在此处添加一些可能有用的信息。 我的SQlite缓存db文件大小有时会疯狂增加,这会导致DB打开和关闭操作变慢。 通常这个文件没有超过500KB的数据,但有时会突然达到40MB,从而减慢了操作速度。</ p>
</ div>



Yii Cache was working fine for me until today when I saw DB exception in a script using cache:

exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 5 database is locked. The SQL statement executed was: DELETE FROM YiiCache WHERE id='9ccac723c84ae75582784f9e3738d781'' in C:\xampp\htdocs\framework\db\CDbCommand.php:336

I have no idea why this error came up while everything was normal a minute before. After that I saw couple of more same exceptions Yii cache and then another:

exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 table YiiCache already exists. The SQL statement executed was: CREATE TABLE YiiCache
        id CHAR(128) PRIMARY KEY,
        expire INTEGER,
        value BLOB
)' in C:\xampp\htdocs\framework\db\CDbCommand.php:336

Since cache is being used on many places in the code so I cannot put the try catch everywhere, instead I would like to settle the root cause. This problem was solved when I removed the db cache file and framework started a new file. The old file size was around 71MB.



Yii Framework: 1.1.8

PHP version: 5.3.8

Please let me know so I can avoid this in future.

Thank you


I would like to add some information here which might be helpful. My SQlite cache db file size increases insanely sometimes which causes the slower DB open and close operations. Normally this file does not have more then 500KB data but sometimes suddenly it goes upto 40MB and hence slowdown the operations.

Csdn user default icon