Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5hqx-00057i-FT for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2022 06:36:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p5hqw-0007SL-41 for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2022 06:36:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5hqu-0007SB-DC for pgsql-hackers@lists.postgresql.org; Thu, 15 Dec 2022 06:36:21 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5hqq-0001vi-8V for pgsql-hackers@postgresql.org; Thu, 15 Dec 2022 06:36:19 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 4112E320091C; Thu, 15 Dec 2022 01:36:13 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 15 Dec 2022 01:36:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1671086172; x=1671172572; bh=miZQtA/RKv AKURbvXMHXAtiTee8pJzlg1LcvDRNAVf0=; b=NtMkZNVr9Y6SOMQuYGcqEf04e4 MjPhFJi19RNM5WvIaLRKUjFiywRq4i4kjSRtxx4e/x9K4wY65HU4GloyiqqBJ9f3 VS4ukNMX82RqjQBcfALeQEhNRkxobGT4xLOWgXDa6OmOCR9ICTDpwuBq7ZxEulxF ySxbuxcpw4FPR0WrSLsoksHqAxAQKUZ9S6rCxHqZbQoC5RbtzK61coO7Rsdb5YAd Jys1RoUyc6ZnZ59lnQ/7uTV4dYFtaK5D0ksTJFaIW0s/Ea3Fhpm9vql61lAM7kiN yJfktvIcbmcF38cvhRWrThZWbbYCwK3kuIhBeKit2fhR3TtRPrwda9Gat7og== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1671086172; x=1671172572; bh=miZQtA/RKvAKURbvXMHXAtiTee8p Jzlg1LcvDRNAVf0=; b=TU92u1ZEuL+iAP3IovIv+uUqJAKZhTh7anxwqre1A1/P Raff6hZ+5hyHkZxXqhuaNDDhCm1tGZi03UrJgS0uQgcsmAyQIk/BgyzWjxt/VSwO 05i21QgdxLSir2sQTGEmf7vCcQkPrCkxWDOj03FxiBzq8FESZM9WbQHSu5GXoppk FiTydXFye3L4men2GD5a32weUqofeefFiBV3cP5f0J/TqsaRLRfCb+hdaFoOA/iM DDyw3SHugkZNjomRMRdh//e3uENE5UlOLoUP7ALetc+jQySnV/vVN7p77H4XNq6+ 48AEPYovSjwsFXqsyNs4kJu14UdaqqM0M66IPTj+Uw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeggdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 15 Dec 2022 01:36:09 -0500 (EST) Date: Thu, 15 Dec 2022 15:36:06 +0900 From: Michael Paquier To: David Christensen Cc: Bharath Rupireddy , Justin Pryzby , Ian Lawrence Barwick , Matthias van de Meent , pgsql-hackers@postgresql.org Subject: Re: [PATCH] Teach pg_waldump to extract FPIs from the WAL Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pPjI34RbK/8yHj76" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --pPjI34RbK/8yHj76 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 14, 2022 at 04:44:34PM -0600, David Christensen wrote: > I can get one sent in tomorrow. -XLogRecordHasFPW(XLogReaderState *record) +XLogRecordHasFPI(XLogReaderState *record) This still refers to a FPW, so let's leave that out as well as any renamings of this kind.. + if (config.save_fpi_path !=3D NULL) + { + /* Create the dir if it doesn't exist */ + if (pg_mkdir_p(config.save_fpi_path, pg_dir_create_mode) < 0) + { + pg_log_error("could not create output directory \"%s\": %m", + config.save_fpi_path); + goto bad_argument; + } + } It seems to me that you could allow things to work even if the directory exists and is empty. See for example verify_dir_is_empty_or_create() in pg_basebackup.c. +my $file_re =3D + qr/^([0-9A-F]{8})-([0-9A-F]{8})[.][0-9]+[.][0-9]+[.][0-9]+[.][0-9]+(?:_v= m|_init|_fsm|_main)?$/; This is artistic to parse for people not used to regexps (I do, a little). Perhaps this could use a small comment with an example of name or a reference describing this format? +# Set umask so test directories and files are created with default permiss= ions +umask(0077); Incorrect copy-paste coming from elsewhere like the TAP tests of pg_basebackup with group permissions? Doesn't=20 PostgreSQL::Test::Utils::tempdir give already enough protection in terms of umask() and permissions? + if (config.save_fpi_path !=3D NULL) + { + /* We fsync our output directory only; since these files are not pa= rt + * of the production database we do not require the performance hit + * that fsyncing every FPI would entail, so are doing this as a + * compromise. */ + + fsync_fname(config.save_fpi_path, true); + } Why is it necessary to flush anything at all, then? +my $relation =3D $node->safe_psql('postgres', + q{SELECT format('%s/%s/%s', CASE WHEN reltablespace =3D 0 THEN dattablespace ELSE reltablespace END, pg_database.oid, pg_relation_filenode(pg_class.oid)) FROM pg_class, pg_database WHERE relname =3D 'test_table' AND datname =3D current_database()} Could you rewrite that to be on multiple lines? +diag "using walfile: $walfile"; You should avoid the use of "diag", as this would cause extra output noise with a simple make check. +$node->safe_psql('postgres', "SELECT pg_drop_replication_slot('regress_pg_= waldump_slot')") That's not really necessary, the nodes are wiped out at the end of the test.=20 +$node->safe_psql('postgres', <