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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 94F45627CC for ; Wed, 30 Sep 2020 15:43:25 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8031019B3C for ; Wed, 30 Sep 2020 15:42:55 +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 10ED419B2F for ; Wed, 30 Sep 2020 15:42:52 +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 C734F458E9 for ; Wed, 30 Sep 2020 15:42:51 +0200 (CEST) To: Thomas Lamprecht , Proxmox Backup Server development discussion References: <20200930132522.22927-1-s.reiter@proxmox.com> <20200930132522.22927-2-s.reiter@proxmox.com> <102da918-162c-fcf4-f1e7-68b46b63f953@proxmox.com> From: Stefan Reiter Message-ID: Date: Wed, 30 Sep 2020 15:42:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <102da918-162c-fcf4-f1e7-68b46b63f953@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.047 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) 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. [environment.rs] Subject: Re: [pbs-devel] [PATCH proxmox-backup 1/5] backup: don't validate chunk existance if base was recently verified 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: Wed, 30 Sep 2020 13:43:25 -0000 On 9/30/20 3:32 PM, Thomas Lamprecht wrote: > On 30.09.20 15:25, Stefan Reiter wrote: >> If the base was successfully verified within the last 7 days, we assume >> that it is okay and all chunks exist, so we don't have to check. >> >> Signed-off-by: Stefan Reiter >> --- >> src/api2/backup/environment.rs | 29 ++++++++++++++++++++++++++++- >> 1 file changed, 28 insertions(+), 1 deletion(-) >> >> diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs >> index d515bf30..be06d1dc 100644 >> --- a/src/api2/backup/environment.rs >> +++ b/src/api2/backup/environment.rs >> @@ -457,6 +457,31 @@ impl BackupEnvironment { >> Ok(()) >> } >> >> + fn last_backup_has_recent_verify(&self) -> Result { >> + match &self.last_backup { >> + Some(last_backup) => { >> + let last_dir = &last_backup.backup_dir; >> + let (manifest, _) = self.datastore.load_manifest(last_dir)?; >> + let verify = manifest.unprotected["verify_state"].clone(); >> + match serde_json::from_value::>(verify) { >> + Ok(verify) => match verify { >> + Some(verify) => { >> + let cutoff = unsafe { libc::time(std::ptr::null_mut()) }; >> + let cutoff = cutoff - 60*60*24*7; // one week back > > Why unsafe and why not our `proxmox::tools::time::epoch_i64()` ? > Didn't know that exists, I've seen that unsafe a few times so I thought that was the usual way. I'll send v2. > > on another note: we should probably add some helper for getting the > verify state > I'll see if it's feasible. So far we only have two sites that both do different things on individual errors, so I'm not sure how much that would simplify things. >> + Ok(verify.state == VerifyState::Ok && verify.upid.starttime > cutoff) >> + }, >> + None => Ok(false) >> + }, >> + Err(err) => { >> + self.worker.warn(format!("error parsing base verification state : '{}'", err)); >> + Ok(false) >> + } >> + } >> + }, >> + None => Ok(false) >> + } >> + } >> + >> /// Ensure all chunks referenced in this backup actually exist. >> /// Only call *after* all writers have been closed, to avoid race with GC. >> /// In case of error, mark the previous backup as 'verify failed'. >> @@ -534,7 +559,9 @@ impl BackupEnvironment { >> } >> } >> >> - self.verify_chunk_existance(&state.known_chunks)?; >> + if !self.last_backup_has_recent_verify()? { >> + self.verify_chunk_existance(&state.known_chunks)?; >> + } >> >> // marks the backup as successful >> state.finished = true; >> > >