Skip to main content

WalTxn

Struct WalTxn 

Source
pub struct WalTxn<'a, F: FileBackend = FileHandle> { /* private fields */ }
Expand description

An in-progress WAL transaction.

Buffers (page_id, page_body) pairs in memory; the actual disk writes happen at WalTxn::commit. This is how group commit works: many calls to WalTxn::append amortise one sync_data.

Implementations§

Source§

impl<F: FileBackend> WalTxn<'_, F>

Source

pub fn append(&mut self, page_id: PageId, page: &Page) -> Result<()>

Append (page_id, page) to the transaction. The frame is held in memory until WalTxn::commit.

§Errors

Returns Error::InvalidArgument if the resulting WAL size would exceed Config::wal_size_limit.

Source

pub fn append_header(&mut self, page: &Page) -> Result<()>

M6 #51: append a file-header (page-0) frame to the transaction. The WAL frame carries page_id = 0; recovery’s WalkState::absorb routes it into a dedicated header slot. Used by crate::pager::Pager::commit when crate::pager::Pager::set_root_catalog dirtied the in-memory header.

§Errors

As Self::append.

Source

pub fn staged_frame_count(&self) -> usize

Number of frames currently staged in this transaction.

Source

pub fn commit(self) -> Result<Lsn>

Commit the transaction. Writes every staged frame to disk, stamps the last one as the commit marker, performs one sync_data(sync_mode), and returns the LSN of the last frame.

An empty transaction is a no-op and returns the current next_lsn - 1.

§Errors

Returns Error::Io on syscall failure.

Source

pub fn drain_staged(self) -> Vec<(PageId, Page)>

Drain the staged frames into an owned Vec so the pager can merge them into its in-memory view after a successful commit. Called by WalTxn::commit_returning_view (see pager::commit).

Trait Implementations§

Source§

impl<'a, F: Debug + FileBackend> Debug for WalTxn<'a, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, F> Freeze for WalTxn<'a, F>

§

impl<'a, F> RefUnwindSafe for WalTxn<'a, F>
where F: RefUnwindSafe,

§

impl<'a, F> Send for WalTxn<'a, F>
where F: Send,

§

impl<'a, F> Sync for WalTxn<'a, F>
where F: Sync,

§

impl<'a, F> Unpin for WalTxn<'a, F>

§

impl<'a, F> UnsafeUnpin for WalTxn<'a, F>

§

impl<'a, F = FileHandle> !UnwindSafe for WalTxn<'a, F>

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<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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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