package granary
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11
doc/granary.storage/Granary_storage/Pager/index.html
Module Granary_storage.PagerSource
Pager: page cache + allocator over a BLOCK backend.
type wal_callbacks = {wal_find_page : int64 -> int option;wal_find_page_at : int64 -> max_frame:int -> int option;wal_read_frame : int -> (Cstruct.t, string) result Lwt.t;wal_append_commit : (int64 * Cstruct.t) list -> (unit, string) result Lwt.t;wal_append_commit_no_sync : (int64 * Cstruct.t) list -> (unit, string) result Lwt.t;wal_sync : unit -> (unit, string) result Lwt.t;
}Pretty-print a pager error.
Pretty-print the pager state (n_pages, cache/dirty sizes, txn_id).
val create :
read_page:(page_id:int64 -> Cstruct.t -> (unit, string) result Lwt.t) ->
write_page:(page_id:int64 -> Cstruct.t -> (unit, string) result Lwt.t) ->
sync:(unit -> (unit, string) result Lwt.t) ->
resize:(n_pages:int64 -> (unit, string) result Lwt.t) ->
n_pages:int64 ->
freelist:Freelist.t ->
tCreate a pager over BLOCK callbacks with the given initial page count and freelist.
Set the schema-fingerprint stamp for subsequently-built Btree pages (#174).
#384: attach/detach a synchronous observer for physical page I/O events (internals monitor). None (the default) is zero-overhead. The observer must be cheap and non-blocking; exceptions it raises are NOT caught here — Store.set_event_callback wraps the store-level observer to swallow them.
Set the file's page geometry (called once on open, before any page op).
Current page geometry.
Attach or detach the WAL overlay. Clears cache on transition into WAL mode.
val read :
?snapshot_frames:int ->
?pin_set:(int64, unit) Hashtbl.t ->
?bypass_cache:bool ->
t ->
int64 ->
(Cstruct.t, error) result Lwt.tRead page_id, consulting dirty (writer path) or the WAL snapshot. When ~bypass_cache:true, the page is read from the block device but NOT inserted into the shared FIFO cache. Intended for single-use pages such as BLOB overflow chains where caching would evict hot B-tree pages without benefit. On a cache hit the cached buffer is still returned even when bypass_cache is set; only insertion-on-miss is suppressed.
val read_borrow :
?snapshot_frames:int ->
?pin_set:(int64, unit) Hashtbl.t ->
?bypass_cache:bool ->
t ->
int64 ->
(Cstruct.t -> 'a Lwt.t) ->
('a, error) result Lwt.tZero-copy borrow-read: the callback receives the page buffer directly. When ~bypass_cache:true, the page is read from the block device but NOT inserted into the shared FIFO cache. See read for details.
Write buf to page_id (takes ownership, no defensive copy).
#356: the LIVE dirty buffer for page_id (NOT a copy), or None if the page is not dirty in the current write txn. A dirty page was allocated or CoW-copied by this txn, so no committed snapshot or concurrent reader references it — the caller may mutate it in place. Mutations must keep the page well-formed; the CRC reseals at flush time.
Allocate a page: txn-owned pool, then main freelist, then file extension.
Free page_id stamped with freed_at_txn_id; txn-owned pages route to the pool.
Flush all dirty pages to the WAL without an fsync.
Flush dirty pages directly to the main BLOCK device with an fsync.
Flush a single page to the main BLOCK device.
Current freelist state.
Set the minimum safe txn ID for freelist reuse (gated by active readers).
Replace the entire freelist (used by rollback and checkpoint).
Override n_pages (used by savepoint rollback to truncate the file).
Snapshot the dirty set (for savepoints).
Restore a dirty set snapshot (for savepoints).
Release every pin held by an RO snapshot (#159).
Set the page count threshold at rw_begin; pages >= this are txn-owned.
Current txn-owned page pool (freed pages available for reuse).