--- On Wed, 14/3/12, Dan Kennedy <[email protected]> wrote:
> From: Dan Kennedy <[email protected]> > Subject: Re: [sqlite] Sqlite compile options for multithreaded application > To: [email protected] > Date: Wednesday, 14 March, 2012, 5:20 PM > On 03/14/2012 06:09 PM, rahul dev > wrote: > > Guys, > > > > I am using sqlite version > 3.7.10. My application is multi-threaded and each thread > opens a separate connection to the the same database file. > > I want my database operations to be thread-safe and as > concurrent as possible. Can you please tell me what sqlite > compile flags should I use ? > > > > I am passing THREADSAFE=2. Is that right ? > > Or should I use THREADSAFE=1 ? But, in that case even > the concurrent reads will be serialized. So, THREADSAFE=2 > seems to be a better option ? > > With THREADSAFE=1, calls made on a single database handle > are serialized. But calls made on separate handles may > still > run concurrently. THREADSAFE=2 just allows you to avoid the > overhead imposed by the mutex used to serialize the calls > made on a single database handle. > > You can also change the threading model using > sqlite3_config() > at runtime. > > > > > Secondly, I am running the application on a > propreitary > filesystem/operating-system that does *NOT* support unix > like file > locking semantics. However, flock() is supported on my > system. What > option should I pass so that "dotlockLockingStyle" or > "unix-flock" may > be used ? > > > > Pass something like "unix-flock" as the fourth argument to > sqlite3_open_v2() when opening the database connection. > > > If I pass 'SQLITE_ENABLE_LOCKING_STYLE', my compilation > fails with > > error error: storage size of 'fsInfo' isn't known cc1: > warnings being > > treated as errors /src/sqlite3.c:30079: error: > implicit declaration of function 'fstatfs' > > > > Is this a known problem ? What should I do to take care > of the above > compilation problem ? > Thanks a lot, Dan for your help. I just found that "fcntl" locks are also supported on my system. So, I do not need to pass 'SQLITE_ENABLE_LOCING_STYLE'. I believe that if I do not pass 'SQLITE_ENABLE_LOCING_STYLE', then the default locking style (fcntl) will be used. Is that correct ? I am using THREADSAFE=2. I want to know if there are any other sqlite compile flags that I should use which may be useful. (for better speed efficiency) ? In the older sqlite version, I used to pass 'SQLITE_OMIT_FAULTINJECTOR' flag. This flag is not available in the latest version of sqlite. Is there any flag equivalent to 'SQLITE_OMIT_FAULTINJECTOR' in newest version of sqlite ? Any other flag that you guys feel should be passed during compilation ? On a debug build I am passing 'SQLITE_LOCK_TRACE' to ensure that locks are working fine. But, I get following error on compilation, /src/sqlite3.c: In function 'lockTrace': /src/sqlite3.c:25521: error: implicit declaration of function 'sqlite3DebugPrintf' /src/sqlite3.c: In function 'openDirectory': /src/sqlite3.c:28250: error: passing argument 3 of 'lockTrace' makes pointer from integer without a cast Any idea what should I do to resolve above compilation error. thanks a lot, rahul _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

