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
impl PerCoreWalManager
Sourcepub fn new(config: PerCoreWalConfig) -> Result<Self, PerCoreWalError>
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.
Sourcepub fn open(config: PerCoreWalConfig) -> Result<Self, PerCoreWalError>
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.
Sourcepub fn config(&self) -> &PerCoreWalConfig
pub fn config(&self) -> &PerCoreWalConfig
Returns the configuration.
Sourcepub fn epoch_ref(&self) -> Arc<AtomicU64>
pub fn epoch_ref(&self) -> Arc<AtomicU64>
Returns a shared reference to the global epoch counter.
Sourcepub fn writer(&mut self, core_id: usize) -> &mut CoreWalWriter
pub fn writer(&mut self, core_id: usize) -> &mut CoreWalWriter
Sourcepub fn writer_checked(
&mut self,
core_id: usize,
) -> Result<&mut CoreWalWriter, PerCoreWalError>
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.
Sourcepub fn advance_epoch(&self) -> u64
pub fn advance_epoch(&self) -> u64
Advances the global epoch and returns the new epoch.
Sourcepub fn set_epoch_all(&mut self, epoch: u64)
pub fn set_epoch_all(&mut self, epoch: u64)
Sets the epoch on all writers.
Sourcepub fn sync_all(&mut self) -> Result<(), PerCoreWalError>
pub fn sync_all(&mut self) -> Result<(), PerCoreWalError>
Sourcepub fn positions(&self) -> Vec<u64>
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.
Sourcepub fn synced_positions(&self) -> Vec<u64>
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.
Sourcepub fn truncate_all(&mut self, positions: &[u64]) -> Result<(), PerCoreWalError>
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.
Sourcepub fn reset_all(&mut self) -> Result<(), PerCoreWalError>
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.
Sourcepub fn merge_segments(&self) -> Result<Vec<PerCoreWalEntry>, PerCoreWalError>
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.
Sourcepub fn merge_segments_up_to_epoch(
&self,
max_epoch: u64,
) -> Result<Vec<PerCoreWalEntry>, PerCoreWalError>
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.
Sourcepub fn write_epoch_barrier_all(&mut self) -> Result<(), PerCoreWalError>
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.
Sourcepub fn check_all_completions(
&mut self,
completions: &[IoCompletion],
) -> Result<usize, PerCoreWalError>
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.
Sourcepub fn any_sync_pending(&self) -> bool
pub fn any_sync_pending(&self) -> bool
Returns true if any writer has a pending sync.
Sourcepub fn total_size(&self) -> u64
pub fn total_size(&self) -> u64
Returns total size of all segments.
Sourcepub fn segment_path(&self, core_id: usize) -> PathBuf
pub fn segment_path(&self, core_id: usize) -> PathBuf
Returns segment path for a core.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PerCoreWalManager
impl RefUnwindSafe for PerCoreWalManager
impl Send for PerCoreWalManager
impl Sync for PerCoreWalManager
impl Unpin for PerCoreWalManager
impl UnsafeUnpin for PerCoreWalManager
impl UnwindSafe for PerCoreWalManager
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.