On 9/10/2016 1:16 PM, Olivier Mascia wrote:
Le 10 sept. 2016 à 11:21, Alexander Täschner
<alexandertaesch...@googlemail.com> a écrit :
since upgrading to Windows 10 I have trouble with several different C#
programs I wrote, that uses System.Data.SQLite to access sqlite
database files
...
The programs are using multiple threads sharing one SQLiteConnection
per process. I use lock statements to prevent the different threads from
accessing this connection object and all derived SQLiteCommand
objects simultaneously.
One connection per process, shared between threads is calling for needless
complications (your efforts to prevent different threads from using this
connection object simultaneously, for instance).
I would first refactor this a little bit, in order for each thread to use their
own connection, not sharing any of these, nor any of the descendant objects
from those connections. It is very simple to do and you will get rid of all
that code to handle mutual exclusion. In essence, you program each thread as
if they were a distinct process (regarding SQLite). It *might% fix your
problem or help you find where it exactly is. And if you're using WAL mode, it
will bring you some level of true read-concurrency.
In your current model, you should make sure that SQLite library is set for:
sqlite3_config(SQLITE_CONFIG_SERIALIZED); // SQLite enforces a mutual
exclusion of threads
And in the 'each thread has its own connection(s)' model which I suggest, you
could downgrade that to:
sqlite3_config(SQLITE_CONFIG_MULTITHREAD); // SQLite does NO attempt to
isolate threads (because you do
// by giving a distinct
connection to each and every thread)
I don't know what the default it with System.Data.SQLite.
Default is Serialized for SQLite and System.Data.SQLite, and
it's probably best to leave it at that even when each thread
has it's own connection. More info:
https://sqlite.org/threadsafe.html
I'd do as Olivier suggests and refactor the code a little.
Welcome to Windows 10 ;)
-Bill
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users