THREADSAFE is about entrance requirements and has nothing whatsoever to do with reading/writing or transactions.
--- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Nick >Sent: Monday, 12 February, 2018 20:49 >To: sqlite-users@mailinglists.sqlite.org >Subject: Re: [sqlite] Question about threadsafe > >Thank you Keith. And there are something I want to make sure. > >>THREADSAFE=1 means that the sqlite3 library enforces the re-entrancy >requirements via mutexes attached to the CONNECTION object. This >means that >the library will serialize access to the sqlite3 engine for you so >that only >one call (entrance) per connection is permitted to proceed. >Yes. That's the reason why I think my applications can use >"threadsafe=1 + >share one connection" directly and sqlite will meeting the entrance >requirements by itself. > >>Other entrances (calls) will *wait* until the in-progress call is >complete >before proceeding. >I see the word "wait". But could you give me any advises to find the >code >when sqlite waiting or retrying? > >>THREADSAFE=2 means that the sqlite3 library WILL NOT ENFORCE the >re-entrancy requirements via mutexes attatched to the CONNECTION >object. >Yes. So I can not use "threadsafe=2 + share one connection" in my >apps, as I >may have more than one call at a time. > >>The limitation of only ONE entrance per connection object at one >time is >still in effect however, so if you violate the rules then AHWBL. >I want to make sure that it is not OK to read and write concurrently >within >the same transaction(two thread share one connection), but it is OK >to read >and write concurrently if I have two different connection and use >WAL. Is it >correct? > >>Therefore IF you use THREADSAFE=2 *AND* open a new connection >dedicated to >each thread, THEN you can be sure that you are meeting the entrance >requirements provided that only calls against that connection (or >objects >derived therefrom) are made on the thread which owns that connection, >and >from NO OTHER THREAD. >Sorry, I still can not understand. Um, or, is it OK to use >"threadsafe=2 and >2 connections" in my apps if the 2 threads may write at the same >time? > >thanks. > > > > > > > >-- >Sent from: http://sqlite.1065341.n5.nabble.com/ >_______________________________________________ >sqlite-users mailing list >sqlite-users@mailinglists.sqlite.org >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users