Nick wrote: > I use sqlite3_open() to open two connections, and I have configured > journal_mode=WAL, threadsafe=2. > > Connection 1 is doing: > sqlite3_exec(db1, "BEGIN", 0, 0, &zErrMsg); > sqlite3_exec(db1, "SELECT * FROM t1;", 0, 0, &zErrMsg); > sqlite3_exec(db1, "INSERT INTO t1 VALUES(1, 1, \"aa\”)”, 0, 0, &zErrMsg); > //SQLITE_BUSY > sqlite3_exec(db1, "COMMIT", 0, 0, &zErrMsg); > > I got that SQLITE_BUSY as connection 2 was writing the db at the same time. > I have called sqlite3_busy_timeout() but I find that it does not work if > INSERT runs after a SELECT within BEGIN and COMMIT.
When you have two connections that upgrade from a read-only transaction to a read-write transaction, you would get a deadlock. Use "BEGIN IMMEDIATE" instead to tell the DB that you intend to write. Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users