pub(crate) async fn hand_over<S: LogStore>(
region: &MitoRegion,
wal: &Wal<S>,
node_id: Option<u64>,
source_node_id: Option<u64>,
upto: EntryId,
candidate: Option<CandidateLease<'_>>,
) -> Result<(PendingManifestHook, RegionEdit)>Expand description
Hands a region whose manifest is published conditionally over to this node node_id, which
becomes its writer, from the source node source_node_id that reported upto as its last
entry or, in a takeover (candidate is set), whose WAL listing returned upto, a bound at or
above every entry in the listed objects; entries of the source above upto are not recovered.
Replays nothing.
The log store first hands the region over (see Wal::handoff); a takeover also waits for the
lease of its candidate meanwhile. Then the catchup commits, after the manifest the region
holds (in a takeover, the version it began from), this node’s handoff floor, the bound that
hand-off returned, and, if upto is above where the manifest recovers the source’s WAL from,
a tail of the source up to upto (of kind Reported, or Listed in a takeover), raising the
committed sequence by HANDOVER_SEQUENCE_GAP. The tail is replayed in the background once the
region is writable.
Returns the receipt of the manifest hook and the committed edit, which the region’s worker applies to the region’s version, in order with the edits of flushes and compactions.
Fails before the log store handoff if there are entries to recover and the request names no source, or if the region has no sequences left for another handover.