pub fn wal_watermarks(root: &Path, node: u32) -> Result<Watermarks>Expand description
How far the write-ahead log has been absorbed into published blocks, per
signal, in the order crate::wal::Signal::index uses.
This is the whole of WAL recovery’s input, and it is three readdirs — the
same ones the read path does at boot anyway. No manifest file, so nothing
that can disagree with the blocks it describes.
The maximum over the blocks, not the last one published: scan sorts by
timestamp, and a block covering an older hour can be published after a
newer one when a late export arrives. Taking the last would then walk the
watermark backwards and replay data that is already stored.
A signal with no blocks gets 0 — replay everything the log holds for it,
which is right, because nothing has absorbed any of it.
node scopes it to one writer’s blocks, and that is not an optimisation.
Sequences are per-log: crate::wal::Wal hands them out from its own
counter, so two replicas sharing a volume (section 12) number their frames
independently and a sequence means nothing outside the log that issued it.
An unscoped maximum therefore hands the quiet replica the busy one’s
progress, and both consumers act on it destructively — crate::wal::Wal::replay
skips every frame below it, and wal_sweep unlinks the segments holding
them. The blocks are still filtered by nothing else: scan returns the whole
directory because the read path wants every replica’s blocks, and only
recovery wants one replica’s.