LCOV - differential code coverage report
Current view: top level - safekeeper/src - remove_wal.rs (source / functions) Coverage Total Hit UBC CBC
Current: cd44433dd675caa99df17a61b18949c8387e2242.info Lines: 89.5 % 19 17 2 17
Current Date: 2024-01-09 02:06:09 Functions: 60.0 % 5 3 2 3
Baseline: 66c52a629a0f4a503e193045e0df4c77139e344b.info
Baseline Date: 2024-01-08 15:34:46

           TLA  Line data    Source code
       1                 : //! Thread removing old WAL.
       2                 : 
       3                 : use std::time::Duration;
       4                 : 
       5                 : use tokio::time::sleep;
       6                 : use tracing::*;
       7                 : 
       8                 : use crate::{GlobalTimelines, SafeKeeperConf};
       9                 : 
      10 CBC         485 : pub async fn task_main(conf: SafeKeeperConf) -> anyhow::Result<()> {
      11             485 :     let wal_removal_interval = Duration::from_millis(5000);
      12                 :     loop {
      13            2067 :         let tlis = GlobalTimelines::get_all();
      14            4028 :         for tli in &tlis {
      15            1961 :             if !tli.is_active().await {
      16             115 :                 continue;
      17            1846 :             }
      18            1846 :             let ttid = tli.ttid;
      19            1846 :             async {
      20            1846 :                 if let Err(e) = tli.maybe_persist_control_file().await {
      21 UBC           0 :                     warn!("failed to persist control file: {e}");
      22 CBC        1846 :                 }
      23            1846 :                 if let Err(e) = tli.remove_old_wal(conf.wal_backup_enabled).await {
      24 UBC           0 :                     error!("failed to remove WAL: {}", e);
      25 CBC        1846 :                 }
      26            1846 :             }
      27            1846 :             .instrument(info_span!("WAL removal", ttid = %ttid))
      28             258 :             .await;
      29                 :         }
      30            2067 :         sleep(wal_removal_interval).await;
      31                 :     }
      32                 : }
        

Generated by: LCOV version 2.1-beta