On Tuesday, 6 August, 2019 04:35, test user <example.com.use...@gmail.com> 
wrote:

>When SQLITE_THREADSAFE=(1, SERIALIZED), how are the reads/writes
>queued? Is it per connection, file, or process?

>Quote: I don't know exactly what you mean by "how are read/writes
>queued".

>Quote: if you make two simultaneous calls on the same connection
>(from different threads, for example), one of them will get the mutex and
>proceed immediately, and the other one will have to wait until that mutex is
>released

>What I mean by "queue" is that if one request is waiting until a
>mutex is released, it is in an implicit queue for that resource.

>I wanted to know how this queue works:

>- Does the second request just take longer to return from the FFI
>call whilst waiting for the mutex?

>- Or does the FFI return SQLITE_BUSY and expect the caller to call
>again in the future?

Being that this is an Operating System provided MUTEX I would expect that the 
subsequent entry merely waits in the OS queue until it is able to obtain the 
mutex.  There is a #define that you can make at compile time 
(SQLITE_ENABLE_MULTITHREADED_CHECKS) that will chuck an message to the log if 
you use MULTITHREADED and then violate the rules anyway.

Without looking though the code in detail the above is my expectation, however, 
I suppose you could get an SQLITE_BUSY / SQLITE_MISUSE return if you attempt 
something that you should not be doing, like trying to do something 
simultaneously from multiple threads on the same connection.

Only one of the devs familliar with the mutex system everywhere it is used 
would know the answer to this without either (a) experimenting or (b) searching 
widely through the code looking for how each particular instance of a mutex is 
handled.

However, since the default is SERIALIZED I would expect that the SERIALIZATION 
occurs without notification to the programmer that it has been done.

-- 
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to