If multiple connections in shared cache mode are treated as a single "real" connection, should I change the thread mode to Serialized? I tough this "single" connection was in terms of page cache and would not have any implications on how the connections are accessed (or not) concurrently, especially transaction control.
Either way, the example you gave does not apply. What was happening with my code was that a transaction A started at T1, inserted a row and was committed successfully at T2. Another transaction B started at T3 and didn't see the new row. I can't see how the fact that transaction A was in shared cache mode and B in private cache mode could influence the new row not being seen in transaction B, when its transaction started after transaction A commit. Doesn't this break ACID? On Mon, Jun 23, 2014 at 3:34 AM, Igor Tandetnik <i...@tandetnik.org> wrote: > On 6/22/2014 6:33 PM, João Ramos wrote: > >> What happens is this: - a thread acquires the write DB connection - that >> thread inserts a new row in a table and gets its id - the thread releases >> the write DB connection (so that other threads can use it) - the same >> thread acquires (its own) read-only DB connection - thread tries to read >> the row it just inserted and it returns NULL >> > > Well, it's a *shared* cache. All connections reading from the cache must > needs see the same data - namely, the data observed by the oldest > still-open transaction. > > A shared cache is an in-memory construct that holds a single "real" > connection to the actual database file; all connections to the shared cache > go through this single "real" connection. Say, connection A starts reading > at time T - this initiates a read transaction on the "real" connection. > Connection B starts reading at time T+2 - that becomes part of the same > transaction. A may stop reading (e.g. reset its statement) at time T+3 - > but B still reads the data as it existed at time T, and cannot observe any > changes made at T+1. > -- > Igor Tandetnik > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users