wasm_redb_reader (wasm_redb v0.1.0)
View SourceOne reading guest of a database opened with readers.
wasm_redb_db starts one of these per reader, linked to it. Each owns a
guest that opens the file as a redb ReadOnlyDatabase, in redb's
SingleWriter mode, and follows the commits of the writing guest through
the database's lock table (wasm_storage_lock). Readers serve the reads
and read transactions that wasm_redb sends them, one at a time each, so
several readers serve one database in parallel.
A reader handles failures as the database server does, for its own guest
only: a deadline, a trap or a storage error stops the guest, every read
transaction it had is lost (transaction_lost), and the reader opens the
file again at once. The writer and the other readers carry on.
Implicit reads (a read given the database rather than a transaction) share
one read transaction while nothing has been committed: the database server
counts its writes in an atomics cell and bumps it before it answers, and a
reader starts a new transaction when the count has moved. A read that starts
after a commit returned therefore always sees it. Every 100 ms the reader
drops the shared transaction if the count has moved or no read used it, so
a quiet reader does not keep the writer from reusing pages.
Transactions are {r, Index, Generation, Id}. Use it through wasm_redb;
the messages are internal.
Summary
Functions
Close the guest; the next request opens it again.
End the read transaction implicit reads share, before maintenance that needs every transaction closed.
Functions
-spec close_guest(pid()) -> ok.
Close the guest; the next request opens it again.