I have two threads that are writing 2000 rows each to the same  
database at the same time.
I am using sqlite 3.6.13 compiled with SQLITE_THREADSAFE=1.

Each client executes this code (pseudo C code):
void write (sqlite3 *db) {
        int i;

        for (i=1; i<=2000; i++) {
                if (sqlite3_get_autocommit(db) != 0) sqlite3_exec(db, "BEGIN  
IMMEDIATE;", ...);
                sqlite3_exec(db, "INSERT INTO....", ...);
                if (sqlite3_get_autocommit(db) == 0) sqlite3_exec(db, 
"COMMIT;", ...);
        }       
}
and db is shared between the two clients.

At the end of the loop, instead of having 4000 rows I have 3976 rows  
(it's random, sometimes I have 3972 or 3974).
sqlite3_exec doesn't returns any error during the INSERT statement,  
but I have some errors during the BEGIN IMMEDIATE, errors are all:
SQL logic error or missing database (printed with sqlite3_errmsg).

Any explanation of the possible causes for the missed rows?
Thanks.
-- 
Marco Bambini





_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to