public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal
@ 2024-06-24 14:24 Christian Ebner
  2024-06-24 15:53 ` Dietmar Maurer
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2024-06-24 14:24 UTC (permalink / raw)
  To: pbs-devel

In certain situations garbage might be written to the rrd journal,
e.g. by a hard crash of the host.
Therefore, skip not only non-parsable lines, as is already the case,
but also skip over lines containing non-utf8 contents.

Reported in the community forum:
https://forum.proxmox.com/threads/149542/

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
Tested by writing garbage to the `rrd.journal` located at
`/var/lib/proxmox-backup/rrdb` via `dd`.

Not only does this lead to the summary graphs in the WebUI not being
updated anymore, but also the systemd journal is being spammed with
apply old journal messages after a reboot, potentially filling up the
available disk space.

 proxmox-rrd/src/cache.rs | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs
index 5b123a6b..96c92fd8 100644
--- a/proxmox-rrd/src/cache.rs
+++ b/proxmox-rrd/src/cache.rs
@@ -280,11 +280,21 @@ fn apply_journal_lines(
     loop {
         linenr += 1;
         let mut line = String::new();
-        let len = if lock_read_line {
+        let result = if lock_read_line {
             let _lock = state.read().unwrap(); // make sure we read entire lines
-            reader.read_line(&mut line)?
+            reader.read_line(&mut line)
         } else {
-            reader.read_line(&mut line)?
+            reader.read_line(&mut line)
+        };
+
+        let len = match result {
+            Ok(len) => len,
+            Err(err) => {
+                log::warn!(
+                    "unable to parse rrd journal '{journal_name}' line {linenr} (skip) - {err}",
+                );
+                continue;
+            }
         };
 
         if len == 0 {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal
  2024-06-24 14:24 [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal Christian Ebner
@ 2024-06-24 15:53 ` Dietmar Maurer
  2024-06-24 17:30   ` Christian Ebner
  0 siblings, 1 reply; 6+ messages in thread
From: Dietmar Maurer @ 2024-06-24 15:53 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Christian Ebner

> In certain situations garbage might be written to the rrd journal,
> e.g. by a hard crash of the host.

Why does a host crash writes garbage to a file?


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal
  2024-06-24 15:53 ` Dietmar Maurer
@ 2024-06-24 17:30   ` Christian Ebner
  2024-06-28 12:09     ` Wolfgang Bumiller
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2024-06-24 17:30 UTC (permalink / raw)
  To: Dietmar Maurer, Proxmox Backup Server development discussion

On 6/24/24 17:53, Dietmar Maurer wrote:
>> In certain situations garbage might be written to the rrd journal,
>> e.g. by a hard crash of the host.
> 
> Why does a host crash writes garbage to a file?

I did not investigate any further how the file corruption might have 
occurred: might be truncated output leading to incorrect, non-utf8 
encoding before the full line was written?

Nevertheless, the reported error message points to this location and the 
line should be skipped if not correctly encoded, no matter how the file 
was corrupted to begin with. Otherwise the mentioned issues arise.


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal
  2024-06-24 17:30   ` Christian Ebner
@ 2024-06-28 12:09     ` Wolfgang Bumiller
  2024-06-28 12:20       ` Christian Ebner
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Bumiller @ 2024-06-28 12:09 UTC (permalink / raw)
  To: Christian Ebner; +Cc: Proxmox Backup Server development discussion

On Mon, Jun 24, 2024 at 07:30:55PM GMT, Christian Ebner wrote:
> On 6/24/24 17:53, Dietmar Maurer wrote:
> > > In certain situations garbage might be written to the rrd journal,
> > > e.g. by a hard crash of the host.
> > 
> > Why does a host crash writes garbage to a file?
> 
> I did not investigate any further how the file corruption might have
> occurred: might be truncated output leading to incorrect, non-utf8 encoding
> before the full line was written?

Do we even have anything non-ASCII in that file?
I'd think the file got corrupted some other way.
So would we really want to apply it? Perhaps just let the admin
clear/remove it?


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal
  2024-06-28 12:09     ` Wolfgang Bumiller
@ 2024-06-28 12:20       ` Christian Ebner
  2024-06-28 12:25         ` Lukas Wagner
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2024-06-28 12:20 UTC (permalink / raw)
  To: Wolfgang Bumiller; +Cc: Proxmox Backup Server development discussion

> On 28.06.2024 14:09 CEST Wolfgang Bumiller <w.bumiller@proxmox.com> wrote:
> Do we even have anything non-ASCII in that file?
> I'd think the file got corrupted some other way.
> So would we really want to apply it? Perhaps just let the admin
> clear/remove it?

No, the file should per se be valid UTF-8, even ASCII only.
I already replied to the user to clean up the file to solve the issue, fine by me if this is discarded.


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal
  2024-06-28 12:20       ` Christian Ebner
@ 2024-06-28 12:25         ` Lukas Wagner
  0 siblings, 0 replies; 6+ messages in thread
From: Lukas Wagner @ 2024-06-28 12:25 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Christian Ebner,
	Wolfgang Bumiller



On  2024-06-28 14:20, Christian Ebner wrote:
>> On 28.06.2024 14:09 CEST Wolfgang Bumiller <w.bumiller@proxmox.com> wrote:
>> Do we even have anything non-ASCII in that file?
>> I'd think the file got corrupted some other way.
>> So would we really want to apply it? Perhaps just let the admin
>> clear/remove it?
> 
> No, the file should per se be valid UTF-8, even ASCII only.
> I already replied to the user to clean up the file to solve the issue, fine by me if this is discarded.
> 

The journal is applied on daemon startup and every 30 mins - so it should be fine
to just discard it, one loses only up to 30mins of metric data - which doesn't
sound so bad for a rare data corruption like this.

-- 
- Lukas


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-28 12:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-24 14:24 [pbs-devel] [PATCH proxmox-rrd] cache: skip non-utf8 lines in rrd journal Christian Ebner
2024-06-24 15:53 ` Dietmar Maurer
2024-06-24 17:30   ` Christian Ebner
2024-06-28 12:09     ` Wolfgang Bumiller
2024-06-28 12:20       ` Christian Ebner
2024-06-28 12:25         ` Lukas Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal