pub struct VolumeLock { /* private fields */ }Expand description
A host-wide advisory lock that serialises migrations sharing one volume.
Twelve nodes on one 492 GiB volume each need roughly their live payload free to copy and each return rather more when they retire, so one at a time the host gains space and the queue accelerates. All twelve at once need twelve times the space and all twelve stall. The lock is taken non-blocking: a node that cannot get it simply waits for the next tick.
Where the lock file sits is lock_path_for’s decision (private, so this is not a
link), and this doc used to describe
a branch of it that a running node almost never reaches: the parent of the node root is
the last resort, taken only when the root’s own metadata cannot be read. What a node
normally uses is the host’s temporary directory keyed by the volume’s device id, or the
directory named by LOCK_DIR_ENV when one is set.
Which of those is right is a fact about the deployment that no node can check for
itself, and getting it wrong is silent: every node takes a lock of its own and reports
success. That is why the path is logged when the lock is taken, and why a host whose
nodes do not share a /tmp has to be told where the lock lives.
The directory has to be one only the node’s own user can write. A predictable path in a
world-writable /tmp can be created and held by any local user, who could then keep
every node on the host from ever migrating.
Implementations§
Source§impl VolumeLock
impl VolumeLock
Sourcepub fn try_acquire(root_dir: &Path, scope: Option<&Path>) -> LockAttempt
pub fn try_acquire(root_dir: &Path, scope: Option<&Path>) -> LockAttempt
Try to take the lock for the volume hosting root_dir.
Trait Implementations§
Source§impl Debug for VolumeLock
impl Debug for VolumeLock
Source§impl Drop for VolumeLock
impl Drop for VolumeLock
Auto Trait Implementations§
impl Freeze for VolumeLock
impl RefUnwindSafe for VolumeLock
impl Send for VolumeLock
impl Sync for VolumeLock
impl Unpin for VolumeLock
impl UnsafeUnpin for VolumeLock
impl UnwindSafe for VolumeLock
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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