From c17fbbbc07cdbb9202bae3b1b7cfc1c03ebaa550 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 18 Oct 2021 11:57:19 +0200 Subject: [PATCH] proxmox-rrd: log all errors from apply_and_commit_journal_thread (but only once) --- proxmox-rrd/src/cache.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs index c3969686..0fd49d72 100644 --- a/proxmox-rrd/src/cache.rs +++ b/proxmox-rrd/src/cache.rs @@ -154,19 +154,17 @@ impl RRDCache { let mut state_guard = self.state.write().unwrap(); let journal_applied = state_guard.journal_applied; - let now = proxmox_time::epoch_f64(); - let wants_commit = (now - state_guard.last_journal_flush) > self.config.apply_interval; - - if journal_applied && !wants_commit { return Ok(journal_applied); } if let Some(ref recv) = state_guard.apply_thread_result { match recv.try_recv() { Ok(Ok(())) => { // finished without errors, OK + state_guard.apply_thread_result = None; } Ok(Err(err)) => { // finished with errors, log them log::error!("{}", err); + state_guard.apply_thread_result = None; } Err(TryRecvError::Empty) => { // still running @@ -175,10 +173,16 @@ impl RRDCache { Err(TryRecvError::Disconnected) => { // crashed, start again log::error!("apply journal thread crashed - try again"); + state_guard.apply_thread_result = None; } } } + let now = proxmox_time::epoch_f64(); + let wants_commit = (now - state_guard.last_journal_flush) > self.config.apply_interval; + + if journal_applied && !wants_commit { return Ok(journal_applied); } + state_guard.last_journal_flush = proxmox_time::epoch_f64(); let (sender, receiver) = bounded(1);