LCOV - code coverage report
Current view: top level - safekeeper/src - remove_wal.rs (source / functions) Coverage Total Hit
Test: fc67f8dc6087a0b4f4f0bcd74f6e1dc25fab8cf3.info Lines: 0.0 % 12 0
Test Date: 2024-09-24 13:57:57 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. We hold WAL till it is consumed
       6              : /// by all of 1) pageserver (remote_consistent_lsn) 2) peers 3) s3
       7              : /// offloading.
       8              : /// While it is safe to use inmem values for determining horizon,
       9              : /// we use persistent to make possible normal states less surprising.
      10              : /// All segments covering LSNs before horizon_lsn can be removed.
      11            0 : pub(crate) fn calc_horizon_lsn(state: &StateSnapshot, extra_horizon_lsn: Option<Lsn>) -> Lsn {
      12              :     use std::cmp::min;
      13              : 
      14            0 :     let mut horizon_lsn = min(
      15            0 :         state.cfile_remote_consistent_lsn,
      16            0 :         state.cfile_peer_horizon_lsn,
      17            0 :     );
      18            0 :     // we don't want to remove WAL that is not yet offloaded to s3
      19            0 :     horizon_lsn = min(horizon_lsn, state.cfile_backup_lsn);
      20            0 :     if let Some(extra_horizon_lsn) = extra_horizon_lsn {
      21            0 :         horizon_lsn = min(horizon_lsn, extra_horizon_lsn);
      22            0 :     }
      23              : 
      24            0 :     horizon_lsn
      25            0 : }
        

Generated by: LCOV version 2.1-beta