From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4DAFD60263 for ; Tue, 8 Sep 2020 13:12:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3EA979434 for ; Tue, 8 Sep 2020 13:12:46 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 27E02942A for ; Tue, 8 Sep 2020 13:12:45 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E8B384442D for ; Tue, 8 Sep 2020 13:12:44 +0200 (CEST) Date: Tue, 08 Sep 2020 13:12:29 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20200908091804.27685-1-s.reiter@proxmox.com> In-Reply-To: <20200908091804.27685-1-s.reiter@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1599563352.ezakbc52qx.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, datastore.rs] Subject: Re: [pbs-devel] [PATCH proxmox-backup] gc: attach context to index reader errors and ignore NotFound X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2020 11:12:46 -0000 On September 8, 2020 11:18 am, Stefan Reiter wrote: > Ignore NotFound errors during phase 1, this just means that a snapshot > was forgotten or pruned between scanning for .fidx/.didx files and > actually opening the index to touch the chunks. I originally had a similar patch already lying around, but I am not sure=20 whether this is not too dangerous in the face of transient errors? I'd much rather get to a point where we are sure that no concurrent=20 prune/forget operation can happen, and treat all errors as errors,=20 instead of treating all not found errors as benign 'must have happened=20 cause of concurrent actions'. this is not pull, or download/restore, where we can just retry later -=20 if we skip the index here, all the chunks it referenced are up for=20 garbage collection unless they are saved by another index! >=20 > ignore_notfound has to be a real function, since generics are not > supported for closures. >=20 > The open methods for dynamic and fixed indices are switched from the > usual format_err! to err.context() to allow checking for the root error > (and thus the io::ErrorKind) further up the call chain. >=20 > Signed-off-by: Stefan Reiter > --- > src/backup/datastore.rs | 28 ++++++++++++++++++++++++---- > src/backup/dynamic_index.rs | 5 ++++- > src/backup/fixed_index.rs | 7 +++++-- > 3 files changed, 33 insertions(+), 7 deletions(-) >=20 > diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs > index ebe47487..1f455d64 100644 > --- a/src/backup/datastore.rs > +++ b/src/backup/datastore.rs > @@ -426,6 +426,20 @@ impl DataStore { > Ok(()) > } > =20 > + fn ignore_notfound(res: Result) -> Result, Er= ror> { > + match res { > + Ok(t) =3D> Ok(Some(t)), > + Err(err) =3D> { > + if let Some(ioerr) =3D err.downcast_ref::() { > + if ioerr.kind() =3D=3D std::io::ErrorKind::NotFound = { > + return Ok(None); > + } > + } > + Err(err) > + } > + } > + } > + > fn mark_used_chunks(&self, status: &mut GarbageCollectionStatus, wor= ker: &WorkerTask) -> Result<(), Error> { > =20 > let image_list =3D self.list_images()?; > @@ -443,11 +457,17 @@ impl DataStore { > =20 > if let Ok(archive_type) =3D archive_type(&path) { > if archive_type =3D=3D ArchiveType::FixedIndex { > - let index =3D self.open_fixed_reader(&path)?; > - self.index_mark_used_chunks(index, &path, status, wo= rker)?; > + if let Some(index) =3D Self::ignore_notfound(self.op= en_fixed_reader(&path))? { > + self.index_mark_used_chunks(index, &path, status= , worker)?; > + } else { > + worker.warn(format!("warning: could no longer fi= nd fixed index '{:?}'", &path)); > + } > } else if archive_type =3D=3D ArchiveType::DynamicIndex = { > - let index =3D self.open_dynamic_reader(&path)?; > - self.index_mark_used_chunks(index, &path, status, wo= rker)?; > + if let Some(index) =3D Self::ignore_notfound(self.op= en_dynamic_reader(&path))? { > + self.index_mark_used_chunks(index, &path, status= , worker)?; > + } else { > + worker.warn(format!("warning: could no longer fi= nd dynamic index '{:?}'", &path)); > + } > } > } > done +=3D 1; > diff --git a/src/backup/dynamic_index.rs b/src/backup/dynamic_index.rs > index f70aa44f..a7ce0f24 100644 > --- a/src/backup/dynamic_index.rs > +++ b/src/backup/dynamic_index.rs > @@ -86,7 +86,10 @@ impl DynamicIndexReader { > File::open(path) > .map_err(Error::from) > .and_then(Self::new) > - .map_err(|err| format_err!("Unable to open dynamic index {:?= } - {}", path, err)) > + .map_err(|err| { > + let msg =3D format!("Unable to open dynamic index {:?} -= {}", path, err); > + err.context(msg) > + }) > } > =20 > pub fn new(mut file: std::fs::File) -> Result { > diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs > index 5d6cc1ff..bf864173 100644 > --- a/src/backup/fixed_index.rs > +++ b/src/backup/fixed_index.rs > @@ -1,4 +1,4 @@ > -use anyhow::{bail, format_err, Error}; > +use anyhow::{bail, Error}; > use std::io::{Seek, SeekFrom}; > =20 > use super::chunk_stat::*; > @@ -62,7 +62,10 @@ impl FixedIndexReader { > File::open(path) > .map_err(Error::from) > .and_then(|file| Self::new(file)) > - .map_err(|err| format_err!("Unable to open fixed index {:?} = - {}", path, err)) > + .map_err(|err| { > + let msg =3D format!("Unable to open fixed index {:?} - {= }", path, err); > + err.context(msg) > + }) > } > =20 > pub fn new(mut file: std::fs::File) -> Result { > --=20 > 2.20.1 >=20 >=20 >=20 > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel >=20 >=20 >=20 =