From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH 2/2] rrd: clamp future last_update time on load
Date: Thu, 14 Nov 2024 14:29:50 +0100 [thread overview]
Message-ID: <20241114132950.3536172-2-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20241114132950.3536172-1-t.lamprecht@proxmox.com>
We had already cases reported about systems where the BIOS had a time
rather far in the future and thus anything that requires some time
ordering might fail if it was initialised before an NTP system managed
to sync the clock again.
RRD updates are one such things, so as stop-gap just clam the
last_update time on load.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
it might be nicer to clamp when saving the file, as that also has a
higher chance to a NTP client having run and thus avoiding an error in
the other direction, i.e., when the system is booted with time in the
past. So feell free to take this over and rework for that case, just
sending it out as I had a prototype around for some recent debug session
on my machine.
proxmox-rrd/src/rrd.rs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/proxmox-rrd/src/rrd.rs b/proxmox-rrd/src/rrd.rs
index 4bf4f01b..73a0ebd4 100644
--- a/proxmox-rrd/src/rrd.rs
+++ b/proxmox-rrd/src/rrd.rs
@@ -378,6 +378,11 @@ impl Database {
if rrd.source.last_update < 0.0 {
bail!("rrd file has negative last_update time");
+ } else if rrd.source.last_update > proxmox_time::epoch_f64() {
+ let mut rrd = rrd;
+ log::error!("rrd file has last_update time from the future, clamping to now!");
+ rrd.source.last_update = proxmox_time::epoch_f64();
+ return Ok(rrd);
}
Ok(rrd)
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
prev parent reply other threads:[~2024-11-14 13:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 13:29 [pbs-devel] [PATCH 1/2] rrd: relay error to update database to caller Thomas Lamprecht
2024-11-14 13:29 ` Thomas Lamprecht [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241114132950.3536172-2-t.lamprecht@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox