On Wed, Dec 15, 2010 at 8:34 AM, Yoni Londner <yonih...@gmail.com> wrote:
> Hi, > > I wrote a little program that insert in a loop rows in to the DB, and in > another thread run wal_checkpoint. > After few minutes (6-7) I get (consistently) the following assert error: > > sqlite_test: ..//src/wal.c:1364: walMerge: Assertion `iLeft>=nLeft || > aContent[aLeft[iLeft]]>dbpage' failed. > > I compiled sqlite from fossil, with -DSQLITE_DEBUG and -DSQLITE_TEST > I pasted below the program and the stacks. > Am I doing something wrong? > ... > sqlite3_config(SQLITE_CONFIG_MULTITHREAD); > Read about SQLITE_CONFIG_MULTITHREAD here: http://www.sqlite.org/threadsafe.html MULTITHREAD is not safe to use with two or more threads sharing the same database connection. The underlying error here is that you are attempting to use threads in the first place. You should never do that. Threads are evil and should be avoided wherever possible. Use separate processes for concurrency. Threads in application programs always result in subtle bugs (such as this one) that are hard to reproduce and waste countless hours of developer time. Just say "no" to threads. > conn = sql_open_conn(); > sql_exec(conn, "PRAGMA journal_mode=WAL"); > sql_exec(conn, "PRAGMA synchronous=normal"); > sql_exec(conn, "PRAGMA temp_store=memory"); > sql_exec(conn, "PRAGMA wal_autocheckpoint=-1"); > sql_exec(conn, "create table tbl1 (one varchar(20), two varchar(20))"); > if (pthread_create(&thread, NULL, thread_do, NULL)) > { > printf("could not start thread\n"); > exit(1); > } > do_insert(conn); > sqlite3_close(conn); > printf("Finished\n"); > return 0; > } > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users