开发者

Getting error that the database is locked when refreshing the page

开发者 https://www.devze.com 2022-12-31 21:38 出处:网络
I am running apache wi开发者_JS百科th mod mono and my asp.net app is using mono sqlite as its db. When i refresh the page twice i get the DB is locked error. The folder it is in is chmod 777. The weba

I am running apache wi开发者_JS百科th mod mono and my asp.net app is using mono sqlite as its db. When i refresh the page twice i get the DB is locked error. The folder it is in is chmod 777. The webapp is creating sqlite.db and sqlite.db-journal but it doesnt seem to be able to delete the journal. Also it has problems when i load the page once. It definitely seems to be a permission problem.

i'm confused. What permissions do i need to set these? i tried precreating the files using 777 and had no luck.

-edit- I didnt find a solution however i thought how silly i was being since i was planning to use mysql for my webapp. So i just ported the code and i no longer had issues.


When creating/deleting a file the directory permission matter.

So, if you really want that, you have to set the containing directory's permissions to 777.

Sample:

$ ls -la
total 21
dr-xr-xr-x  2 me me  1024 May 22 19:19 .          #no write permissions to directory
drwxrwxrwt 21 root   root   19456 May 22 19:19 ..
-rwxrwxrwx  1 me me     0 May 22 19:19 abc        #all permissions to file abc
$ rm abc
rm: cannot remove `abc': Permission denied        #abc has 777, but deleting doesn't work
$ chmod 777 .                                     #change directoy's permissions
$ rm abc                                          #now removing works
$ ls                                              #file abc is gone

The reason is that when you delete a file, you actually modify the directory and not the file itself.

Think of a hard link: The file itself will not change when you delete one hardlink to it, but the directory changes.


Sounds more like one instance of the session in apache is blocking the other session, i.e. has the db file open exclusively. Try to let the database(model) run as a singleton (or similar) which all sessions access.

0

精彩评论

暂无评论...
验证码 换一张
取 消