Skip to main content

Pager

Struct Pager 

Source
pub struct Pager { /* private fields */ }
Expand description

Native host adapter for the shared pager.

Implementations§

Source§

impl Pager

Source

pub fn open<P: AsRef<Path>>( path: P, config: PagerConfig, ) -> Result<Self, PagerError>

Open or create a database file

Source

pub fn open_default<P: AsRef<Path>>(path: P) -> Result<Self, PagerError>

Open with default configuration

Source

pub fn read_page_decrypted(&self, page_id: u32) -> Result<Page, PagerError>

Read a page through the configured encryptor if any. Page 0 is always returned plaintext (it carries the encryption marker

  • header). Callers that want raw cipher bytes can use read_page_no_checksum directly.
Source

pub fn write_page_encrypted( &self, page_id: u32, page: Page, ) -> Result<(), PagerError>

Write a page through the configured encryptor if any. Page 0 bypasses encryption and goes through the normal checksummed path. Encrypted pages skip the checksum update because AES-GCM’s authentication tag is the integrity guarantee.

Source

pub fn set_wal_writer(&self, wal: Arc<Mutex<WalWriter>>)

Attach a WAL writer to enforce WAL-first flush ordering.

After this call, [Pager::flush] computes the maximum header.lsn over all dirty pages and calls WalWriter::flush_until(max_lsn) before any page is written to the data file. This is the postgres rule: a page on disk implies its WAL record is already durable on disk.

Existing call sites that construct a Pager without a WAL keep their previous behaviour (no LSN check) — wiring is strictly opt-in.

Source

pub fn clear_wal_writer(&self)

Detach the WAL writer (test / shutdown path).

Source

pub fn has_wal_writer(&self) -> bool

Has a WAL writer been attached?

Source

pub fn prefetch_hint(&self, page_id: u32)

Issue a best-effort OS read-ahead hint under the page-I/O lock.

Methods from Deref<Target = SharedPager<NativePagerFile, NativeWalBarrier>>§

Source

pub fn wal_barrier(&self) -> &W

Source

pub fn lock_ownership_mutations( &self, ) -> ReentrantMutexGuard<'_, RawMutex, RawThreadId, ()>

Hold across an entire ownership publication, not just individual allocation calls. Readers may continue accessing already-published pages.

Source

pub fn fence_interrupted_ownership(&self)

An interrupted publication must be recovered before any more writes.

Source

pub fn fence_file_format_version(&self, version: u32) -> Result<(), PagerError>

Fence a file-format upgrade in both recoverable superblock copies.

The caller must exclude other mutators while the fence is in progress and may publish a new mandatory format only after this succeeds. A failed write fences subsequent mutation until reopen and recovery.

Source

pub fn read_page(&self, page_id: u32) -> Result<Page, PagerError>

Read a page (cache-aware)

Source

pub fn read_page_no_checksum(&self, page_id: u32) -> Result<Page, PagerError>

Read a page without verifying checksum (for encrypted pages)

Use this when the page content has its own integrity protection (e.g., AES-GCM authentication tag for encrypted pages).

Source

pub fn write_page(&self, page_id: u32, page: Page) -> Result<(), PagerError>

Write a page (cache-aware)

Source

pub fn write_page_no_checksum( &self, page_id: u32, page: Page, ) -> Result<(), PagerError>

Write a page without updating checksum (for encrypted pages)

Use this when the page content has its own integrity protection (e.g., AES-GCM authentication tag for encrypted pages).

Source

pub fn allocate_page(&self, page_type: PageType) -> Result<Page, PagerError>

Allocate a new page

Source

pub fn reserve_contig_extent( &self, n_pages: u32, ) -> Result<ExtentId, PagerError>

Reserve a contiguous extent of vector pages.

Source

pub fn free_page(&self, page_id: u32) -> Result<(), PagerError>

Free a page (return to freelist)

Source

pub fn enable_deferred_reclamation(&self) -> Result<(), PagerError>

Source

pub fn deferred_reclamation_pages( &self, ) -> Result<(Vec<u32>, Vec<u32>), PagerError>

Source

pub fn restore_deferred_reclamation( &self, pages: &[u32], ) -> Result<(), PagerError>

Source

pub fn complete_deferred_publication( &self, retained: &[u32], released: &[u32], ) -> Result<(), PagerError>

The caller has durably published a catalog that retains retained and no longer names released, after waiting for old tree readers.

Source

pub fn record_retirement_intent(&self, pages: &[u32]) -> Result<(), PagerError>

Record the pages whose catalog ownership is about to be retired.

Source

pub fn free_retired_pages(&self, pages: &[u32]) -> Result<(), PagerError>

Return a fully validated, unpublished tree generation in one allocator mutation. Call only after its removal from the manifest is durable.

Source

pub fn recover_unowned_pages(&self, pages: &[u32]) -> Result<(), PagerError>

Add proven-unowned pages to the allocator exactly once during recovery. The caller must exclude all allocation and publication until this state has been synced to both superblocks and the journal is completed.

Source

pub fn validate_owned_pages(&self, pages: &[u32]) -> Result<(), PagerError>

Reject a recovery plan if any page it must preserve is already free. The caller must exclude allocation and freelist mutation during recovery.

Source

pub fn sync_recovered_allocator(&self) -> Result<(), PagerError>

Persist the current allocator in both fallback copies during recovery. The caller must exclude allocation until journal completion is durable.

Source

pub fn free_page_count(&self) -> Result<u32, PagerError>

Get database header Pages available to the allocator, including pages on unloaded trunks.

Source

pub fn header(&self) -> Result<DatabaseHeader, PagerError>

Source

pub fn physical_header(&self) -> Result<PhysicalFileHeader, PagerError>

Source

pub fn update_physical_header( &self, physical: PhysicalFileHeader, ) -> Result<(), PagerError>

Source

pub fn page_count(&self) -> Result<u32, PagerError>

Get page count

Source

pub fn flush(&self) -> Result<(), PagerError>

Flush all dirty pages to disk

Source

pub fn sync(&self) -> Result<(), PagerError>

Sync file to disk (fsync)

Source

pub fn cache_stats(&self) -> CacheStats

Get cache statistics

Source

pub fn cache_len(&self) -> usize

Pages currently resident in the page cache. Slots are fixed size, so this times the page size is the cache’s memory footprint (ADR 0073 §2).

Source

pub fn cache_capacity(&self) -> usize

Preallocated page-cache slots — the sizing this process derived from its page-cache budget share.

Source

pub fn dirty_page_count(&self) -> usize

Count dirty pages currently in the page cache.

Source

pub fn dirty_fraction(&self) -> f64

Estimated fraction of the page cache holding dirty pages. Returned in [0, 1]. Used by the background writer to decide when to kick in aggressive flushing.

Source

pub fn flush_some_dirty(&self, max: usize) -> Result<usize, PagerError>

Flush up to max dirty pages from the cache. Returns the number actually written. Background-writer entry point — reuses the same persistence path as flush() but bounded.

Source

pub fn path(&self) -> &Path

Get database file path

Source

pub fn is_read_only(&self) -> bool

Check if database is read-only

Source

pub fn file_size(&self) -> Result<u64, PagerError>

Get file size in bytes

Source

pub fn read_manifest_page(&self) -> Result<Page, PagerError>

Read the internal manifest page (page 1), the zone the superblock roots.

ADR 0074 §2: manifest corruption fails the open didactically, naming the zone — it never falls back to a sidecar and never returns garbage.

Source

pub fn write_header_and_sync(&self) -> Result<(), PagerError>

Write header and sync to disk (public for checkpointer).

Source

pub fn set_checkpoint_in_progress( &self, in_progress: bool, target_lsn: u64, ) -> Result<(), PagerError>

Set the checkpoint_in_progress flag in the header.

Source

pub fn complete_checkpoint(&self, lsn: u64) -> Result<(), PagerError>

Update the checkpoint LSN and clear the in-progress flag.

Trait Implementations§

Source§

impl Deref for Pager

Source§

type Target = Pager<NativePagerFile, NativeWalBarrier>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for Pager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl PageStore for Pager

Auto Trait Implementations§

§

impl !Freeze for Pager

§

impl !RefUnwindSafe for Pager

§

impl Send for Pager

§

impl Sync for Pager

§

impl Unpin for Pager

§

impl UnsafeUnpin for Pager

§

impl UnwindSafe for Pager

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool