pub struct MoveRange { /* private fields */ }Expand description
One in-flight move-range: the bookkeeping that carries authority for one range from its current owner to a target without losing a write or letting the target serve early.
Built with begin, which enlists the target as a replica and
captures the catalog CAS (owner / epoch / version) the cutover will use. The
snapshot point and the target’s catch-up progress are filled in as the move
runs. Until cut_over succeeds the catalog is unchanged, so
the old owner keeps serving and the target — a mere replica — cannot.
Implementations§
Source§impl MoveRange
impl MoveRange
Sourcepub fn begin(
catalog: &mut ShardOwnershipCatalog,
collection: CollectionId,
range_id: RangeId,
target: NodeIdentity,
) -> Result<MoveRange, MoveError>
pub fn begin( catalog: &mut ShardOwnershipCatalog, collection: CollectionId, range_id: RangeId, target: NodeIdentity, ) -> Result<MoveRange, MoveError>
Start moving (collection, range_id) to target. Enlists target as a
replica of the range if it is not one already (so the cutover has a valid
promotion candidate), then captures the catalog CAS for the eventual
fenced handoff. The move begins in CopyingSnapshot;
the catalog’s owner is unchanged, so the old owner keeps serving writes.
Fails if the range is unknown or target is already its owner (a move to
the incumbent is a no-op).
pub fn phase(&self) -> MovePhase
pub fn source(&self) -> &NodeIdentity
pub fn target(&self) -> &NodeIdentity
Sourcepub fn snapshot_watermark(&self) -> Option<CommitWatermark>
pub fn snapshot_watermark(&self) -> Option<CommitWatermark>
The consistent point the physical snapshot was taken at, once installed.
Sourcepub fn position(&self) -> Option<RangeStreamPosition>
pub fn position(&self) -> Option<RangeStreamPosition>
The target’s catch-up position over the range-indexed WAL, once catch-up has begun.
Sourcepub fn complete_snapshot(
&mut self,
at: CommitWatermark,
) -> Result<(), MoveError>
pub fn complete_snapshot( &mut self, at: CommitWatermark, ) -> Result<(), MoveError>
Record that the target has installed a consistent physical snapshot taken
at at. Moves the move into CatchingUp and
seeds the catch-up position from the snapshot point: the target has applied
everything up to at and will accept range records ahead of it, fencing
any stamped below the range’s current ownership epoch.
Only valid while copying the snapshot.
Sourcepub fn record_catch_up(
&mut self,
records: &[ChangeRecord],
) -> Result<RangeCatchupPlan, MoveError>
pub fn record_catch_up( &mut self, records: &[ChangeRecord], ) -> Result<RangeCatchupPlan, MoveError>
Replay a slice of the shared logical stream into the target’s range-indexed
catch-up, advancing its applied position past every record stamped for this
range (issue #992). Returns the RangeCatchupPlan so the caller can see
which records applied and which were fenced. Only valid while catching up.
Sourcepub fn catch_up_evidence(&self) -> Option<CatchUpEvidence>
pub fn catch_up_evidence(&self) -> Option<CatchUpEvidence>
The catch-up evidence the cutover will present for the target: the highest
(term, lsn) it has applied for the range. None before a snapshot is
installed.
Sourcepub fn has_caught_up(&self, live: CommitWatermark) -> bool
pub fn has_caught_up(&self, live: CommitWatermark) -> bool
Whether the target’s applied log covers live — the live range commit
watermark, which has advanced past the snapshot point as the old owner kept
writing. The cutover may only proceed once this holds.
Sourcepub fn cut_over(
&mut self,
catalog: &mut ShardOwnershipCatalog,
live: CommitWatermark,
) -> Result<TransitionOutcome, MoveError>
pub fn cut_over( &mut self, catalog: &mut ShardOwnershipCatalog, live: CommitWatermark, ) -> Result<TransitionOutcome, MoveError>
Cut over: move the catalog epoch to the target through the fenced
Handoff transition, demoting the old owner to a
replica. The move must be CatchingUp and the
target must cover live — otherwise this returns
TargetBehindWatermark without
touching the catalog, so a target that has not caught up is never
promoted and the old owner keeps serving.
On success the catalog names the target at a new epoch (fencing the old
owner’s stale-epoch writes) and the move is Completed.
Trait Implementations§
impl Eq for MoveRange
impl StructuralPartialEq for MoveRange
Auto Trait Implementations§
impl Freeze for MoveRange
impl RefUnwindSafe for MoveRange
impl Send for MoveRange
impl Sync for MoveRange
impl Unpin for MoveRange
impl UnsafeUnpin for MoveRange
impl UnwindSafe for MoveRange
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request