Skip to main content

PerCoreWalManager

Struct PerCoreWalManager 

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

Per-core WAL manager.

Coordinates all core WAL writers and provides epoch management. Each core has its own writer, eliminating cross-core synchronization on writes.

Implementations§

Source§

impl PerCoreWalManager

Source

pub fn new(config: PerCoreWalConfig) -> Result<Self, PerCoreWalError>

Creates a new per-core WAL manager.

Creates segment files for all cores if they don’t exist.

§Errors

Returns an error if directory creation or writer initialization fails.

Source

pub fn open(config: PerCoreWalConfig) -> Result<Self, PerCoreWalError>

Opens an existing per-core WAL manager.

All segment files must exist.

§Errors

Returns an error if any segment file doesn’t exist or can’t be opened.

Source

pub fn config(&self) -> &PerCoreWalConfig

Returns the configuration.

Source

pub fn num_cores(&self) -> usize

Returns the number of cores.

Source

pub fn epoch(&self) -> u64

Returns the current global epoch.

Source

pub fn epoch_ref(&self) -> Arc<AtomicU64>

Returns a shared reference to the global epoch counter.

Source

pub fn writer(&mut self, core_id: usize) -> &mut CoreWalWriter

Gets the writer for a specific core.

§Panics

Panics if core_id >= num_cores.

Source

pub fn writer_checked( &mut self, core_id: usize, ) -> Result<&mut CoreWalWriter, PerCoreWalError>

Gets the writer for a specific core, checking bounds.

§Errors

Returns an error if core_id >= num_cores.

Source

pub fn advance_epoch(&self) -> u64

Advances the global epoch and returns the new epoch.

Source

pub fn set_epoch_all(&mut self, epoch: u64)

Sets the epoch on all writers.

Source

pub fn sync_all(&mut self) -> Result<(), PerCoreWalError>

Syncs all segment files.

§Errors

Returns an error if any sync fails.

Source

pub fn positions(&self) -> Vec<u64>

Returns the current write positions of all writers (includes un-synced data).

For checkpoint manifests, prefer synced_positions() which only reports durable data.

Source

pub fn synced_positions(&self) -> Vec<u64>

Returns the last synced (durable) positions of all writers.

Only data up to these positions is guaranteed to survive a crash. Use this for checkpoint manifests.

Source

pub fn truncate_all(&mut self, positions: &[u64]) -> Result<(), PerCoreWalError>

Truncates all segments at the specified positions.

§Errors

Returns an error if any truncation fails.

Source

pub fn reset_all(&mut self) -> Result<(), PerCoreWalError>

Resets (truncates to zero) all segments.

Used after successful checkpoint.

§Errors

Returns an error if any reset fails.

Source

pub fn merge_segments(&self) -> Result<Vec<PerCoreWalEntry>, PerCoreWalError>

Merges entries from all segments, sorted by (epoch, timestamp).

§Errors

Returns an error if reading any segment fails.

Source

pub fn merge_segments_up_to_epoch( &self, max_epoch: u64, ) -> Result<Vec<PerCoreWalEntry>, PerCoreWalError>

Merges entries from all segments up to a specific epoch.

§Errors

Returns an error if reading any segment fails.

Source

pub fn write_epoch_barrier_all(&mut self) -> Result<(), PerCoreWalError>

Writes an epoch barrier to all segments.

Used during checkpoint to mark epoch boundaries.

§Errors

Returns an error if any write fails.

Source

pub fn check_all_completions( &mut self, completions: &[IoCompletion], ) -> Result<usize, PerCoreWalError>

Check I/O completions against all writers’ pending sync tokens.

Call this after polling StorageIo::poll_completions. Each writer that has a pending sync token matching a completion will update its synced_position.

Returns the number of writers whose syncs completed successfully.

§Errors

Returns the first PerCoreWalError encountered if any writer’s sync failed.

Source

pub fn any_sync_pending(&self) -> bool

Returns true if any writer has a pending sync.

Source

pub fn total_size(&self) -> u64

Returns total size of all segments.

Source

pub fn segment_path(&self, core_id: usize) -> PathBuf

Returns segment path for a core.

Trait Implementations§

Source§

impl Debug for PerCoreWalManager

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scope for T

Source§

fn with<F, R>(self, f: F) -> R
where Self: Sized, F: FnOnce(Self) -> R,

Scoped with ownership.
Source§

fn with_ref<F, R>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Scoped with reference.
Source§

fn with_mut<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Scoped with mutable reference.
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

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<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Value for T
where T: Send + Sync + 'static,