Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDb3X-0003Fh-9R for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Oct 2018 20:07:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gDb3U-0006Uh-OX for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Oct 2018 20:07:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDb3U-0006UZ-HI for pgsql-hackers@lists.postgresql.org; Fri, 19 Oct 2018 20:07:32 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDb3S-0007VV-6C for pgsql-hackers@postgresql.org; Fri, 19 Oct 2018 20:07:32 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 450D8C3D; Fri, 19 Oct 2018 16:07:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 19 Oct 2018 16:07:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=U9+9AAieBXIKB0OlpHphU3+P0aW kAOLef27+nVlGskY=; b=jSLel9eE7eLYv0BfcJS+LXhvSOZH8bmxZMFXupm5+++ ynkDRKEYul4r5sc3TrnTvkTd1Ot/pukJMyW9HjagQ0bFuvMsT1vaAEiLc2VRocJ3 YJ/d72nER8kOxu5w8VTb1MFGH0vcVumyOM3VuYRgPdd820PB16tsvvNEYOlAtGxq QjCW7oc3R3XGeGmbD5cLI2rXO0xE1U+I04R4MyxeYQail4SUHzFvMUOmvcJo9arR aC8npFr2rVDen7S3WQHUyhhLSbi/JjMlNv1JQAaYNqFW8K0CjJnKzfSA8oM04Dsf /h1sb+vR2ckhbg9XoWwDRjkrCwZgwPNQloyLibYnsAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=U9+9AA ieBXIKB0OlpHphU3+P0aWkAOLef27+nVlGskY=; b=Xulu8c+L+NWfYdlblOW1Sp 7EDTP7tV1t9x4+ZhjvzPubBYVP1YMppfdYozYFCiI6LtOXbixiKlLZYPD/GcFgmW 7I2Bn4QwfMvHnBS2cc2ljhUtHpPFnumNtDD86RheJhBaVkXPKSPpteKNWaY1YEYP WaZZNpiu3E+RNp3emXKv8k+UerQYJruPG2Fp/x58oYQFNzIN+5Spl4umuZ0L7hcI o/w7LRLERHSxrtTOZWoa7CkpGkH3m+V8A+e8s/UlqqNN6Y5hSmiM6j0L97q20cA7 sBqHuaowkDegxCXSmBU/zefwJG2l7kAkixnUxH6FofMeqZnRatdeKFhpOWgc/7NQ == X-ME-Sender: X-ME-Proxy: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id F002E102A0; Fri, 19 Oct 2018 16:07:24 -0400 (EDT) Date: Fri, 19 Oct 2018 13:07:23 -0700 From: Andres Freund To: Stephen Frost Cc: Michael Paquier , Andrew Dunstan , Tom Lane , Michael Banck , Postgres hackers , Daniel Gustafsson , Magnus Hagander Subject: Re: pgsql: Add TAP tests for pg_verify_checksums Message-ID: <20181019200723.4byzaw5km5jvsxlc@alap3.anarazel.de> References: <20181019135009.GG2099@paquier.xyz> <20181019143659.GJ4184@tamriel.snowman.net> <20181019171747.4uithw2sjkt6msne@alap3.anarazel.de> <20181019175228.GN4184@tamriel.snowman.net> <20181019175908.kc67mfxdlguckask@alap3.anarazel.de> <20181019181103.GO4184@tamriel.snowman.net> <20181019183050.6fgqc5ugnavfzae4@alap3.anarazel.de> <20181019184751.GP4184@tamriel.snowman.net> <20181019192146.j4my7yjzv4eitw2w@alap3.anarazel.de> <20181019195728.GQ4184@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181019195728.GQ4184@tamriel.snowman.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-10-19 15:57:28 -0400, Stephen Frost wrote: > > > > > Of course- the same is true with a crash/restart case, so I'm not sure > > > > > what you're getting at here. > > > > > > > > pg_verify_checksum doesn't support running on a crashed cluster, and I'm > > > > not sure it'd make sense to teach it to so (there's not really much it > > > > could do to discern whether a block is a torn page that replay will fix, > > > > or corrupted). > > > > > > ... and this isn't at all relevant, because pg_basebackup does run on a > > > running cluster. > > > > I wasn't ever denying that or anything close to it? My point is that > > pg_verify_checksum needs much more filtering than it has now to deal > > with that, because it needs to handle all files that could be present, > > not just files that could be present after a graceful shutdown. > > Perhaps it doesn't today but surely one goal of pg_verify_checksum is to > be able to run it on a running cluster eventually. I was saying *precisely* that above. I give up. > > pg_basebackup's case is *not* really comparable because basebackup.c > > already performed a lot of filtering before noChecksumFiles is applied. > > This all really just points out that we should have the code for > handling this somewhere common that both pg_verify_checksum and > pg_basebackup can leverage without duplicating all of it. I never argued against that. My point is that your argument that they started out the same isn't true. > The specific case that started all of this certainly looks pretty > clearly like a case that both need to deal with. Yep. > > > As pointed out elsewhere on this thread, the logic was the same between > > > the two before this commit... The code in pg_basebackup came from the > > > prior pg_verify_checksums code. Certainly, some mention of the code > > > existing in two places, at least, should have been in the comments. > > > > But the filter for basebackup only comes after the pre-existing > > filtering that the basebackup.c code already does. All of: > > > > /* > > * List of files excluded from backups. > > */ > > static const char *excludeFiles[] = > > { > > /* Skip auto conf temporary file. */ > > PG_AUTOCONF_FILENAME ".tmp", > > > > /* Skip current log file temporary file */ > > LOG_METAINFO_DATAFILE_TMP, > > > > /* Skip relation cache because it is rebuilt on startup */ > > RELCACHE_INIT_FILENAME, > > > > /* > > * If there's a backup_label or tablespace_map file, it belongs to a > > * backup started by the user with pg_start_backup(). It is *not* correct > > * for this backup. Our backup_label/tablespace_map is injected into the > > * tar separately. > > */ > > BACKUP_LABEL_FILE, > > TABLESPACE_MAP, > > > > "postmaster.pid", > > "postmaster.opts", > > > > /* end of list */ > > NULL > > }; > > > > is not applied, for example. Nor is: > > > > /* Skip temporary files */ > > if (strncmp(de->d_name, > > PG_TEMP_FILE_PREFIX, > > strlen(PG_TEMP_FILE_PREFIX)) == 0) > > continue; > > > > Nor is > > /* Exclude temporary relations */ > > if (isDbDir && looks_like_temp_rel_name(de->d_name)) > > { > > elog(DEBUG2, > > "temporary relation file \"%s\" excluded from backup", > > de->d_name); > > > > continue; > > } > > > > So, yea, they had: > > > > static const char *const skip[] = { > > "pg_control", > > "pg_filenode.map", > > "pg_internal.init", > > "PG_VERSION", > > NULL, > > }; > > > > in common, but not more. All the above exclusions are strictly > > necessary. > > ... but all of that code doesn't change that pg_basebackup also needs to > ignore the EXEC_BACKEND created config_exec_params/.new files. Right. > You're right, pg_verify_checksums, with the assumption that it only runs > on a cleanly shut-down cluster, doesn't need the temp-file-skipping > logic, today, but it's going to need it tomorrow, isn't it? No, it needs it today, as explain below in the email you're replaying to. > > FWIW, as far as I can tell, pg_verify_checksum appears to be broken in a > > lot of (unfortunately) pretty normal scenarios right now. Not just on > > windows. Besides the narrow window of crashing while a .tmp file is > > present (and then shutting down normally after a crash restart), it also > > has the much of wider window of crashing while *any* backend has > > temporary files/relations. As crash-restarts don't release temp files, > > they'll still be present after the crash, and a single graceful shutdown > > afterwards will leave them in place. No? > > We do go through and do some cleanup at crash/restart We don't clean up temp files tho. * NOTE: we could, but don't, call this during a post-backend-crash restart * cycle. The argument for not doing it is that someone might want to examine * the temp files for debugging purposes. This does however mean that * OpenTemporaryFile had better allow for collision with an existing temp * file name. > As you say, some of those are likely to have checksums, which should be > handled by pg_basebackup and pg_verify_checksums, and that goes back to > the point I was making up-thread that we want to make sure an account > for everything. With this pattern-based approach, we could easily end > up forgetting to add the correct new pattern into pg_verify_checksums. If you're adding checksums for something, you better test it I don't buy this. In contrast it's much more likely that there's a file that's short-lived that you won't easily test against pg_verify_checksum running in that moment. > Playing this further and assuming that extensions dropping files into > tablespace directories is acceptable, what are we supposed to do when > there's some direct conflict between a file that we want to create in a > PG tablespace directory and a file that some extension dropped there? > Create yet another subdirectory which we call > "THIS_IS_REALLY_ONLY_FOR_PG"? Then it's a buggy extension. And we error out. > What about two different extensions wanting to create files with the > same names in the tablespace directories..? > > Experimentation is fine, of course, this is open source code and people > should feel free to play with it, but we are not obligated to avoid > breaking things when an extension author, through their experimentation, > does something which is clearly not supported, like dropping files into > PG's tablespace directories. Further, when it comes to our user's data, > we should be taking a strict approach and accounting for everything, > something that this whitelist-of-patterns-based approach to finding > files to verify the checksums on doesn't do. It's not economically feasible to work on extensions that will only be usable a year down the road. Greetings, Andres Freund