Re: [sqlite] Question about threadsafe

2018-02-16 Thread Keith Medcalf
-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. > >>TH

Re: [sqlite] Question about threadsafe

2018-02-16 Thread Keith Medcalf
ys a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Nick >Sent: Tuesday, 13 February, 2018 23:19 >To: sqlite-users@mailinglists.sqlite.org >Subject: Re: [sqlite] Question

Re: [sqlite] Question about threadsafe

2018-02-14 Thread Simon Slavin
On 14 Feb 2018, at 6:19am, Nick wrote: > Writing in thread 1 will no block SELECTs in thread 2 as I use WAL. But the > INSERT within the transaction of thread 2 still returns SQLITE_BUSY. > I think I have used sqlite3_busy_timeout() in right way and I find that >

Re: [sqlite] Question about threadsafe

2018-02-14 Thread R Smith
I ran a test and I can still find "database is locked" even if I use busy_handler(threadsafe=2, 2 connections). When thread 1 executing a writing transaction, thread 2 runs the code below at the same time: sqlite3_exec("BEGIN") //SELECT sqlite3_prepare_v2("SELECT * FROM t1;"); sqlite3_step;

Re: [sqlite] Question about threadsafe

2018-02-13 Thread Nick
>> So I think "threadsafe=2 + more than 1 connection + busy_handler" is a good >> way to use. >This is the normal way to use SQLite. I ran a test and I can still find "database is locked" even if I use busy_handler(threadsafe=2, 2 connections). When thread 1 executing a writing transaction,

Re: [sqlite] Question about threadsafe

2018-02-13 Thread Keith Medcalf
From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Nick >Sent: Tuesday, 13 February, 2018 02:14 >To: sqlite-users@mailinglists.sqlite.org >Subject: Re: [sqlite] Question about threadsafe > >>> is it OK to use "threadsafe=2 and >>> 2

Re: [sqlite] Question about threadsafe

2018-02-13 Thread Simon Slavin
On 13 Feb 2018, at 9:14am, Nick wrote: > So I think "threadsafe=2 + more than 1 connection + busy_handler" is a good > way to use. This is the normal way to use SQLite. > Another possible way is "threadsafe=1 and share 1 connection", but if thread > 1 begins a

Re: [sqlite] Question about threadsafe

2018-02-13 Thread Nick
>> is it OK to use "threadsafe=2 and >> 2 connections" in my apps if the 2 threads may write at the same time? >Yes. So I think "threadsafe=2 + more than 1 connection + busy_handler" is a good way to use. Another possible way is "threadsafe=1 and share 1 connection", but if thread 1 begins a

Re: [sqlite] Question about threadsafe

2018-02-12 Thread Simon Slavin
On 13 Feb 2018, at 3:49am, Nick wrote: > is it OK to use "threadsafe=2 and > 2 connections" in my apps if the 2 threads may write at the same time? Yes. "When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a

Re: [sqlite] Question about threadsafe

2018-02-12 Thread Nick
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

Re: [sqlite] Question about threadsafe

2018-02-12 Thread Keith Medcalf
o: sqlite-users@mailinglists.sqlite.org >Subject: Re: [sqlite] Question about threadsafe > >I ran several multi-threads tests these days and I want to get a >confirmation >that my understanding is correct. >I use WAL mode and I think whether or not use the same connection >with >TH

Re: [sqlite] Question about threadsafe

2018-02-12 Thread Nick
I ran several multi-threads tests these days and I want to get a confirmation that my understanding is correct. I use WAL mode and I think whether or not use the same connection with THREADSAFE=1, 2 is the key to my question. Mode 1, threadsafe=2 + multiple threads use the same connection: It is

Re: [sqlite] Question about threadsafe

2018-02-07 Thread Kees Nuyt
On Tue, 6 Feb 2018 19:33:10 -0700 (MST), Nick wrote: >> (a) an error result of some kind or (b) a corrupt database. > > I did not see any info about errmsg. Your code doesn't check the returncode of the sqlite3_* calls. >> Are your processes using the same

Re: [sqlite] Question about threadsafe

2018-02-06 Thread Nick
> (a) an error result of some kind or (b) a corrupt database. I did not see any info about errmsg. > Are your processes using the same database connection or does each one > have its own ? Two processes have two sqlite3_open(). So each one has its own. > Are you checking the result codes

Re: [sqlite] Question about threadsafe

2018-02-06 Thread x
Don’t suppose you used ‘INSERT IGNORE’ and the inserts contained duplicate keys? From: Nick Sent: 06 February 2018 11:52 To: sqlite-users@mailinglists.sqlite.org Subject: [sqlite] Question about threadsafe I use

Re: [sqlite] Question about threadsafe

2018-02-06 Thread Simon Slavin
On 6 Feb 2018, at 11:52am, Nick wrote: > But I ran a simple test: > Two processes will run sqlite3_open() respectively to open the same db. Then > both of the two processes will insert 1 records(in Transaction) into the > db simultaneously. > But I find that: >