Jiri Hajek wrote: > Hello, > > I'm trying to use SQLite in an application where it's needed to work with > one database in mutliple threads. Based on all the info I read in SQLite > documentation I create a new database connection for every new thread > created. Each thread does some SELECTs, INSERTs or UPDATEs, but there isn't > any schema modification. If multiple threads are running, I encounter some > strange problems: > > 1. Occasionally after running Sqlite3_step() I get SQLITE_CANTOPEN ('Unable > to open the database file') error. I found out that it can be fixed by > running the query again, i.e. again calling Sqlite3_Prepare(). So this isn't > a big issue, but still I wonder why this error message is returned? > Shouldn't SQLITE_BUSY or SQLITE_LOCKED be returned instead? > > 2. More serious issue is that after I enable transaction usage (not used in > 1.) sometimes (again, it's random) after calling 'BEGIN TRANSACTION' I get > an error SQLITE_ERROR ('cannot start a transaction within a transaction'). > Problem is that I definitely am not already in a transaction. The only > reason for this seems to be that there's >1 thread running, with only 1 > thread running there's no problem. > > I tried this also with the latest version of SQLite (3.3.6 on Windows). > > Any idea what can I do about it? > > Thanks, > Jiri > > > I've seen these same issues myself too on linux/3.3.5, my solution was using our own internal classes to marshal read/write locking ourselves. Cleared everything right up.
-- Bill King, Software Engineer Trolltech, Brisbane Technology Park 26 Brandl St, Eight Mile Plains, QLD, Australia, 4113 Tel + 61 7 3219 9906 (x137) Fax + 61 7 3219 9938 mobile: 0423 532 733