Yes.  If you are starting a transaction in which you know you are going to 
write use BEGIN IMMEDIATE.  Plain BEGIN (BEGIN DEFERRED) starts a READ 
transaction and only attempts to upgrade to a write transaction when you try to 
write.  Since a read transaction in WAL works with a version of the data that 
is current at the time the transaction is started, then you cannot upgrade an 
"old snapshot" for reading to writing (since it cannot "see: the changes being 
made by the in-process transaction).


---
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: Tuesday, 13 February, 2018 23:19
>To: sqlite-users@mailinglists.sqlite.org
>Subject: Re: [sqlite] Question about threadsafe
>
>>> 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, thread 2 runs the code
>below
>at the same time:
>sqlite3_exec("BEGIN")
>//SELECT
>sqlite3_prepare_v2("SELECT * FROM t1;");
>sqlite3_step;
>sqlite3_reset;
>//INSERT
>sqlite3_exec("INSERT INTO t1 VALUES(1, 1, \"aweagsr\")");//database
>is
>locked
>sqlite3_exec("COMMIT");
>
>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
>sqliteDefaultBusyCallback() did not be called.
>
>Is it expected?
>
>
>
>
>--
>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

Reply via email to