LCOV - code coverage report
Current view: top level - safekeeper/src - remove_wal.rs (source / functions) Coverage Total Hit
Test: 8ac049b474321fdc72ddcb56d7165153a1a900e8.info Lines: 90.5 % 21 19
Test Date: 2023-09-06 10:18:01 Functions: 50.0 % 4 2

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

Generated by: LCOV version 2.1-beta