LCOV - differential code coverage report
Current view: top level - safekeeper/src - remove_wal.rs (source / functions) Coverage Total Hit UBC CBC
Current: f6946e90941b557c917ac98cd5a7e9506d180f3e.info Lines: 90.5 % 21 19 2 19
Current Date: 2023-10-19 02:04:12 Functions: 50.0 % 4 2 2 2
Baseline: c8637f37369098875162f194f92736355783b050.info
Baseline Date: 2023-10-18 20:25:20

           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         500 : pub async fn task_main(conf: SafeKeeperConf) -> anyhow::Result<()> {
      11             500 :     let wal_removal_interval = Duration::from_millis(5000);
      12                 :     loop {
      13            1590 :         let tlis = GlobalTimelines::get_all();
      14            2971 :         for tli in &tlis {
      15            1381 :             if !tli.is_active().await {
      16              18 :                 continue;
      17            1363 :             }
      18            1363 :             let ttid = tli.ttid;
      19            1363 :             if let Err(e) = tli
      20            1363 :                 .maybe_persist_control_file()
      21            1363 :                 .instrument(info_span!("", tenant = %ttid.tenant_id, timeline = %ttid.timeline_id))
      22             116 :                 .await
      23                 :             {
      24 UBC           0 :                 warn!("failed to persist control file: {e}");
      25 CBC        1363 :             }
      26            1363 :             if let Err(e) = tli
      27            1363 :                 .remove_old_wal(conf.wal_backup_enabled)
      28            1363 :                 .instrument(info_span!("", tenant = %ttid.tenant_id, timeline = %ttid.timeline_id))
      29             126 :                 .await
      30                 :             {
      31 UBC           0 :                 error!("failed to remove WAL: {}", e);
      32 CBC        1363 :             }
      33                 :         }
      34            1590 :         sleep(wal_removal_interval).await;
      35                 :     }
      36                 : }
        

Generated by: LCOV version 2.1-beta