Skip to main content

AckTracker

Struct AckTracker 

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

Tracks transaction commit acknowledgments from replicas.

When the master commits a transaction, it may need to wait for one or more replicas to acknowledge receipt before considering the transaction durable. The AckTracker manages pending acknowledgments, recording which replicas have acked which VLSNs, and detecting when sufficient acks have been received or when ack timeouts have occurred.

Implementations§

Source§

impl AckTracker

Source

pub fn new() -> Self

Create a new ack tracker.

Source

pub fn register(&self, vlsn: u64, needed_acks: u32)

Register a new VLSN that needs acknowledgments.

If the VLSN is already registered, this is a no-op (the existing registration is preserved).

Source

pub fn record_ack(&self, vlsn: u64, replica_name: &str) -> AckResult

Record an acknowledgment from a replica for a VLSN.

Returns the result indicating whether the ack was accepted and whether it satisfied the durability requirement.

Source

pub fn wait_until_satisfied<F: Fn() -> bool>( &self, vlsn: u64, timeout: Duration, should_abort: F, ) -> bool

Block until vlsn has sufficient acks, the timeout elapses, or should_abort returns true (e.g. shutdown). Returns true if the VLSN became satisfied, false on timeout/abort. Replaces the prior spin-sleep loop — committers park on the condvar and are woken by record_ack (JE FeederTxns.TxnInfo CountDownLatch.await).

Source

pub fn wait_for_predicate<P, A>( &self, timeout: Duration, predicate: P, should_abort: A, ) -> bool
where P: Fn() -> bool, A: Fn() -> bool,

REP-9: park on the ack-signal condvar until predicate() returns true, timeout elapses, or should_abort() returns true. Returns true iff predicate was satisfied. This is the high-water-mark equivalent of wait_until_satisfied for callers that count acks themselves via the per-replica high-water marks (JE FeederManager.getNumCurrentAckFeeders(commitVLSN) counts feeders with getReplicaTxnEndVLSN() >= commitVLSN, not an exact-VLSN match).

Source

pub fn notify_waiters(&self)

REP-9: wake any committer parked in wait_for_predicate / wait_until_satisfied. Used by env.record_ack after it advances a feeder high-water mark, because satisfaction is now decided by the per-replica high-water count (not an exact-VLSN registration), so a record_ack for a VLSN with no exact registration must still wake waiters whose commit_vlsn predicate has just become true.

Source

pub fn is_satisfied(&self, vlsn: u64) -> bool

Check if a VLSN has sufficient acks.

Source

pub fn received_count(&self, vlsn: u64) -> Option<u32>

Number of distinct replica acks recorded for vlsn, or None if no registration exists for that VLSN.

Used by the F1 commit-coordinator path to report the partial ack count when a commit times out without satisfying the configured ReplicaAckPolicy.

Source

pub fn cleanup_through(&self, vlsn: u64)

Remove all pending acks for VLSNs <= the given value.

This is used to clean up acks for transactions that have been durably committed and no longer need tracking.

Source

pub fn pending_count(&self) -> usize

Get the number of pending (unsatisfied) acks.

Source

pub fn check_timeouts(&self, timeout: Duration) -> Vec<u64>

Check for timed-out acks and return their VLSNs.

An ack is considered timed out if it was registered more than timeout ago and has not yet been satisfied.

Side effect: for each unsatisfied, timed-out pending ack found during this scan, total_timeouts is incremented by one.

Source

pub fn get_total_acks(&self) -> u64

Get total number of acks received across all VLSNs.

Source

pub fn get_total_timeouts(&self) -> u64

Get total number of ack timeouts.

Trait Implementations§

Source§

impl Default for AckTracker

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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> 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, 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