pub struct MigrationState {
pub schema: u32,
pub phase: MigrationPhase,
pub first_start_unix: u64,
pub committed_at_unix: Option<u64>,
pub rebuilds_since_commit: u32,
pub shed_key_count: u64,
pub kept_key_count: u64,
}Expand description
The persisted migration marker.
Two facts genuinely need to survive a restart: when this build first ran (so the shed hold is not restarted by a reboot loop) and when the node committed to its file-backed set (so the retirement clock is not either). Everything else is re-derived.
Fields§
§schema: u32Marker schema version.
phase: MigrationPhaseWhere the node is.
first_start_unix: u64Unix seconds when this build first started on this node.
committed_at_unix: Option<u64>Unix seconds when the node committed to its file-backed key set.
rebuilds_since_commit: u32Commitment rebuilds observed since committing.
shed_key_count: u64How many keys the node decided not to keep, for the operator’s benefit.
kept_key_count: u64How many chunks the file store held when the node committed.
Cross-checked at open. A marker claiming the node is past the copying stage while the file store is far emptier than it said means the two disagree about reality, and the filesystem wins.
Implementations§
Source§impl MigrationState
impl MigrationState
Sourcepub fn new(phase: MigrationPhase) -> Self
pub fn new(phase: MigrationPhase) -> Self
A fresh marker for a node that has just started.
Sourcepub fn load_or_create(root_dir: &Path, phase: MigrationPhase) -> Self
pub fn load_or_create(root_dir: &Path, phase: MigrationPhase) -> Self
Load the marker, writing a fresh one if there is none.
Persisting immediately matters: first_start_unix is what the shed hold counts
from, and a marker that is only written at the first phase change would reset that
clock on every restart before then, so a node that restarts more often than the
hold would never become eligible to shed and never finish migrating.
Sourcepub fn load_or_new(root_dir: &Path, phase: MigrationPhase) -> Self
pub fn load_or_new(root_dir: &Path, phase: MigrationPhase) -> Self
Load the marker, or start a fresh one.
An unreadable marker is replaced rather than fatal: it is a hint, and every fact it holds is either recoverable or conservative to reset. Losing it restarts the shed hold and the retirement clock, which delays a migration and never rushes one.
Sourcepub fn save(&self, root_dir: &Path) -> Result<()>
pub fn save(&self, root_dir: &Path) -> Result<()>
Persist the marker so a reader sees either the old content or the new.
§Errors
Returns Error::Storage if the marker cannot be written.
Sourcepub fn shed_hold_elapsed(&self, config: &MigrationConfig) -> bool
pub fn shed_hold_elapsed(&self, config: &MigrationConfig) -> bool
Whether the shed hold has elapsed.
Sourcepub fn retire_delay_elapsed(&self, config: &MigrationConfig) -> bool
pub fn retire_delay_elapsed(&self, config: &MigrationConfig) -> bool
Whether the retirement delay has elapsed since committing.
Trait Implementations§
Source§impl Clone for MigrationState
impl Clone for MigrationState
Source§impl Debug for MigrationState
impl Debug for MigrationState
Source§impl<'de> Deserialize<'de> for MigrationState
impl<'de> Deserialize<'de> for MigrationState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MigrationState
Source§impl PartialEq for MigrationState
impl PartialEq for MigrationState
Source§impl Serialize for MigrationState
impl Serialize for MigrationState
impl StructuralPartialEq for MigrationState
Auto Trait Implementations§
impl Freeze for MigrationState
impl RefUnwindSafe for MigrationState
impl Send for MigrationState
impl Sync for MigrationState
impl Unpin for MigrationState
impl UnsafeUnpin for MigrationState
impl UnwindSafe for MigrationState
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> 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<'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
impl<'de, T> BorrowedRpcObject<'de> for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 more