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
impl AckTracker
Sourcepub fn register(&self, vlsn: u64, needed_acks: u32)
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).
Sourcepub fn record_ack(&self, vlsn: u64, replica_name: &str) -> AckResult
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.
Sourcepub fn wait_until_satisfied<F: Fn() -> bool>(
&self,
vlsn: u64,
timeout: Duration,
should_abort: F,
) -> bool
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).
Sourcepub fn wait_for_predicate<P, A>(
&self,
timeout: Duration,
predicate: P,
should_abort: A,
) -> bool
pub fn wait_for_predicate<P, A>( &self, timeout: Duration, predicate: P, should_abort: A, ) -> 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).
Sourcepub fn notify_waiters(&self)
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.
Sourcepub fn is_satisfied(&self, vlsn: u64) -> bool
pub fn is_satisfied(&self, vlsn: u64) -> bool
Check if a VLSN has sufficient acks.
Sourcepub fn received_count(&self, vlsn: u64) -> Option<u32>
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.
Sourcepub fn cleanup_through(&self, vlsn: u64)
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.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get the number of pending (unsatisfied) acks.
Sourcepub fn check_timeouts(&self, timeout: Duration) -> Vec<u64>
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.
Sourcepub fn get_total_acks(&self) -> u64
pub fn get_total_acks(&self) -> u64
Get total number of acks received across all VLSNs.
Sourcepub fn get_total_timeouts(&self) -> u64
pub fn get_total_timeouts(&self) -> u64
Get total number of ack timeouts.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AckTracker
impl !RefUnwindSafe for AckTracker
impl Send for AckTracker
impl Sync for AckTracker
impl Unpin for AckTracker
impl UnsafeUnpin for AckTracker
impl UnwindSafe for AckTracker
Blanket Implementations§
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> 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 more