SQLite Forum

When committed changes become visible to connections that ATTACH?
Login
Greetings!

I have one sqlite database per process running on the same physical machine where each process can update only its own database. All databases are in WAL mode and stored on the same local file system. Each process is different, has its own responsibilities and process-specific database schema.

Previously, when one process needed to read data from another process, it would make an RPC call. We are replacing such RPCs with an ability to attach other processes' databases and query "remote" tables directly, including queries that join locally-owned tables and tables from another process (this is done using temp views).

With multiple threads sharing a single read-only connection where we first run the ATTACH statement and possibly one or more temp view create statements, are there any guarantees when committed transactions performed by the owning process become visible to readers in another process?

So far, it appears as if so as long as there are overlapping reader threads executing their sequence of prepare() and series of step() calls, new readers that start their work even seconds after the remote process commits its updates, can still be getting old data from
"remote" tables as if no transaction ever happened.

Is that correct?

If so, how could one ensure that updates committed by the owning process are visible to readers from another process? Other than creating a new connection every time.

FWIW, read connections are created using private cache + full mutex option, and all databases are in WAL mode.

Thanks!