Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSAdh-004ljH-G0 for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 07:24:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sSAdf-005q5i-2o for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 07:24:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSAdd-005q4J-SA for pgsql-hackers@lists.postgresql.org; Fri, 12 Jul 2024 07:24:18 +0000 Received: from mail.clear-code.com ([153.126.203.179]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSAdZ-001fRl-Kt for pgsql-hackers@postgresql.org; Fri, 12 Jul 2024 07:24:16 +0000 Received: from localhost (unknown [IPv6:2404:7a80:89c1:1200:6af9:2266:1443:f149]) by mail.clear-code.com (Postfix) with ESMTPSA id A0558D1D49; Fri, 12 Jul 2024 16:24:08 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.clear-code.com A0558D1D49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clear-code.com; s=default; t=1720769048; bh=xTqc0K70owPwnkCCd9d3hMFO4pTFDUYbRSzOLp/Biro=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=R+qU9u/SH5j6iuSpFNHJWaTdcSB7w7KzHpIRWWl68QIZKSR5iGonUZeHKSxaBfmiv Mzd5TGkbZgP/mXX7nH0YntE0IkH3ydcXIJffpjrJW9KornmemSWkw29LvU/pR9Q4Fi tNXy6TrwIs0Lg3H+hV5nuuWmCp4n2Be/HDHoNohw= Date: Fri, 12 Jul 2024 16:24:06 +0900 (JST) Message-Id: <20240712.162406.92904157696470075.kou@clear-code.com> To: cyberdemn@gmail.com Cc: smithpb2250@gmail.com, torikoshia@oss.nttdata.com, horikyota.ntt@gmail.com, michael@paquier.xyz, pgsql-hackers@postgresql.org, bungina@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: pg_rewind WAL segments deletion pitfall From: Sutou Kouhei In-Reply-To: References: <277e2f594a4e64d330fb770debc6a02e@oss.nttdata.com> X-Mailer: Mew version 6.8 on Emacs 29.3 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Jul_12_16_24_06_2024_549)--" Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ----Next_Part(Fri_Jul_12_16_24_06_2024_549)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I'm reviewing patches in Commitfest 2024-07 from top to bottom: https://commitfest.postgresql.org/48/ This is the 1st patch: https://commitfest.postgresql.org/48/3874/ The latest patch can't be applied on master: https://www.postgresql.org/message-id/CAFh8B=nNJtm9ke4_1mhpwGz2PV9yoyF6hMnYh5XACt0AA4VG-A@mail.gmail.com I've rebased on master. See the attached patch. Here are changes for it: * Resolve conflict * Update copyright year to 2024 from 2023 * Add an added test to meson.build * Run pgindent Here are my review comments: @@ -217,6 +221,26 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex, + char xlogfname[MAXFNAMELEN]; + + tli = xlogreader->seg.ws_tli; + segno = xlogreader->seg.ws_segno; + + snprintf(xlogfname, MAXPGPATH, XLOGDIR "/"); + XLogFileName(xlogfname + strlen(xlogfname), + xlogreader->seg.ws_tli, + xlogreader->seg.ws_segno, WalSegSz); + + /* + * Make sure pg_rewind doesn't remove this file, because it is + * required for postgres to start after rewind. + */ + insert_keepwalhash_entry(xlogfname); MAXFNAMELEN is 64 and MAXPGPATH is 1024. strlen(XLOGDIR "/") is 7 because XLOGDIR is "pg_wal". So xlogfname has enough size but snprintf(xlogfname, MAXPGPATH) is wrong usage. (And XLogFileName() uses snprintf(xlogfname, MAXFNAMELEN) internally.) How about using one more buffer? ---- char xlogpath[MAXPGPATH]; char xlogfname[MAXFNAMELEN]; tli = xlogreader->seg.ws_tli; segno = xlogreader->seg.ws_segno; XLogFileName(xlogfname, xlogreader->seg.ws_tli, xlogreader->seg.ws_segno, WalSegSz); snprintf(xlogpath, MAXPGPATH, "%s/%s", XLOGDIR, xlogfname); /* * Make sure pg_rewind doesn't remove this file, because it is * required for postgres to start after rewind. */ insert_keepwalhash_entry(xlogpath); ---- Thanks, -- kou In "Re: pg_rewind WAL segments deletion pitfall" on Tue, 23 Jan 2024 09:23:29 +0100, Alexander Kukushkin wrote: > Hi Peter, > > On Mon, 22 Jan 2024 at 00:38, Peter Smith wrote: > >> 2024-01 Commitfest. >> >> Hi, This patch has a CF status of "Ready for Committer", but it is >> currently failing some CFbot tests [1]. Please have a look and post an >> updated version.. >> >> ====== >> [1] >> https://cirrus-ci.com/github/postgresql-cfbot/postgresql/commitfest/46/3874 >> >> > From what I can see all failures are not related to this patch: > 1. Windows build failed with > [10:52:49.679] 126/281 postgresql:recovery / recovery/019_replslot_limit > ERROR 185.84s (exit status 255 or signal 127 SIGinvalid) > 2. FreeBSD build failed with > [09:11:57.656] 190/285 postgresql:psql / psql/010_tab_completion ERROR > 0.46s exit status 2 > [09:11:57.656] 220/285 postgresql:authentication / > authentication/001_password ERROR 0.57s exit status 2 > > In fact, I don't even see this patch being applied for these builds and the > introduced TAP test being executed. > > Regards, > -- > Alexander Kukushkin ----Next_Part(Fri_Jul_12_16_24_06_2024_549)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="v9-0001-Be-more-picky-with-WAL-segment-deletion-in-pg_rew.patch"