On Fri, May 4, 2012 at 12:21 PM, Paul Thomson <pault...@gmail.com> wrote:

> I am working on a tool that (among other things) can detect data
> races, including file access races. I have detected a file race in
> SQLite on the database file that appears to be real, although I am not
> certain - I have no experience with SQLite. I compiled SQLite with:
> #define SQLITE_THREADSAFE 2
>
> I use a simple test case where two threads call opendb


There is no such function "opendb()" in SQLite, either as an API or
internal.  Did you mean sqlite3_open()?



> on the same
> file, write into the same table and then close the database. The file
> race appears to occur due to sqlite3PagerReadFileheader (as the
> database is opened?) in one thread and pager_write_pagelist in the
> other. It looks as though the page that was written was pgno 1. Can
> any experts explain whether these two accesses are in fact
> synchronised, or if the race is benign?
>

Each database connection will have its own page cache, so access to
internal data structures need not be synchronized.  Access to the disk file
is synchronized using file locks - the exact workings of which depends on
the operating system, which you have left unspecified.


>
> I am using sqlite-amalgamation-3071100. I will later upload the test
> case, trace (showing all calls that are made by each thread) and the
> stack trace for each thread when the race occurs, unless it becomes
> obvious that the above functions cannot race. What is best way to
> provide these files? (attachments? upload to a website and provide a
> link?)
>
> Thanks,
> Paul
> _______________________________________________
> 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

Reply via email to