SQLite and db locking issues, anyone have an idea how to make it work?

Discussion in 'Plugin Development' started by MatCat, Feb 16, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    MatCat

    I can get NPC Trader (My plugin) to work with SQLite, however it gets stuck on db lock issues, I am not completely sure why as I have been super careful to make sure that a DB Connection is only ever open one at a time but if I flood it with queries, I.E. by right clicking on my NPC a bunch of times real fast it will lock up with db lock errors.
    --- merged: Feb 17, 2011 7:21 AM ---
    Quite a few plugins use SQLite someone must have an idea?
     
  2. Offline

    Agnate

    http://www.sqlite.org/faq.html

    Looked here in the SQLite FAQ, at point (5):

    "SQLite uses reader/writer locks to control access to the database. (Under Win95/98/ME which lacks support for reader/writer locks, a probabilistic simulation is used instead.) But use caution: this locking mechanism might not work correctly if the database file is kept on an NFS filesystem. This is because fcntl() file locking is broken on many NFS implementations. You should avoid putting SQLite database files on NFS if multiple processes might try to access the file at the same time. On Windows, Microsoft's documentation says that locking may not work under FAT filesystems if you are not running the Share.exe daemon. People who have a lot of experience with Windows tell me that file locking of network files is very buggy and is not dependable. If what they say is true, sharing an SQLite database between two or more Windows machines might cause unexpected problems."

    [...]

    "When SQLite tries to access a file that is locked by another process, the default behavior is to return SQLITE_BUSY. You can adjust this behavior from C code using the sqlite3_busy_handler() or sqlite3_busy_timeout() API functions."


    Would this possibly explain some of the issues? I'm no SQLite guru, but it sounds like it describes your situation. Sorry I can't provide any more help than that!
     
  3. Offline

    Redecouverte

    do you call Statement.close() after each query?
    --- merged: Feb 17, 2011 7:15 PM ---
    and ResultSet.close()
     
  4. Offline

    sumTard

    someone please help him out so he can get sqlite working with npcs :O
     
  5. Offline

    Bolerodan

    Funny thing is I just started to use SQLite and was thinking of this same issue....
     
Thread Status:
Not open for further replies.

Share This Page