LCOV - code coverage report
Current view: top level - safekeeper/src - remove_wal.rs (source / functions) Coverage Total Hit
Test: b4ae4c4857f9ef3e144e982a35ee23bc84c71983.info Lines: 0.0 % 14 0
Test Date: 2024-10-22 22:13:45 Functions: 0.0 % 1 0

            Line data    Source code
       1              : use utils::lsn::Lsn;
       2              : 
       3              : use crate::timeline_manager::StateSnapshot;
       4              : 
       5              : /// Get oldest LSN we still need to keep.
       6              : ///
       7              : /// We hold WAL till it is consumed by
       8              : /// 1) pageserver (remote_consistent_lsn)
       9              : /// 2) s3 offloading.
      10              : /// 3) Additionally we must store WAL since last local commit_lsn because
      11              : ///    that's where we start looking for last WAL record on start.
      12              : ///
      13              : /// If some peer safekeeper misses data it will fetch it from the remote
      14              : /// storage. While it is safe to use inmem values for determining horizon, we
      15              : /// use persistent to make possible normal states less surprising. All segments
      16              : /// covering LSNs before horizon_lsn can be removed.
      17            0 : pub(crate) fn calc_horizon_lsn(state: &StateSnapshot, extra_horizon_lsn: Option<Lsn>) -> Lsn {
      18              :     use std::cmp::min;
      19              : 
      20            0 :     let mut horizon_lsn = state.cfile_remote_consistent_lsn;
      21            0 :     // we don't want to remove WAL that is not yet offloaded to s3
      22            0 :     horizon_lsn = min(horizon_lsn, state.cfile_backup_lsn);
      23            0 :     // Min by local commit_lsn to be able to begin reading WAL from somewhere on
      24            0 :     // sk start. Technically we don't allow local commit_lsn to be higher than
      25            0 :     // flush_lsn, but let's be double safe by including it as well.
      26            0 :     horizon_lsn = min(horizon_lsn, state.cfile_commit_lsn);
      27            0 :     horizon_lsn = min(horizon_lsn, state.flush_lsn);
      28            0 :     if let Some(extra_horizon_lsn) = extra_horizon_lsn {
      29            0 :         horizon_lsn = min(horizon_lsn, extra_horizon_lsn);
      30            0 :     }
      31              : 
      32            0 :     horizon_lsn
      33            0 : }
        

Generated by: LCOV version 2.1-beta