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 1oxxrj-0001jP-67 for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Nov 2022 22:05:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oxxrh-00014W-KN for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Nov 2022 22:05:09 +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 1oxxrh-00014N-BI for pgsql-hackers@lists.postgresql.org; Wed, 23 Nov 2022 22:05:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oxxrf-0003Wq-4P for pgsql-hackers@postgresql.org; Wed, 23 Nov 2022 22:05:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2ANM53Tp3748784; Wed, 23 Nov 2022 17:05:03 -0500 From: Tom Lane To: Thomas Munro cc: Andres Freund , pgsql-hackers@postgresql.org Subject: Re: odd buildfarm failure - "pg_ctl: control file appears to be corrupt" In-reply-to: References: <20221123014224.xisi44byq3cf5psi@awork3.anarazel.de> Comments: In-reply-to Thomas Munro message dated "Thu, 24 Nov 2022 10:59:26 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3748782.1669241103.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 23 Nov 2022 17:05:03 -0500 Message-ID: <3748783.1669241103@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro writes: > On Wed, Nov 23, 2022 at 11:03 PM Thomas Munro w= rote: >> I assume this is ext4. Presumably anything that reads the >> controlfile, like pg_ctl, pg_checksums, pg_resetwal, >> pg_control_system(), ... by reading without interlocking against >> writes could see garbage. I have lost track of the versions and the >> thread, but I worked out at some point by experimentation that this >> only started relatively recently for concurrent read() and write(), >> but always happened with concurrent pread() and pwrite(). The control >> file uses the non-p variants which didn't mash old/new data like >> grated cheese under concurrency due to some implementation detail, but >> now does. Ugh. > As for what to do about it, some ideas: > 2. Retry after a short time on checksum failure. The probability is > already miniscule, and becomes pretty close to 0 if we read thrice > 100ms apart. > First thought is that 2 is appropriate level of complexity for this > rare and stupid problem. Yeah, I was thinking the same. A variant could be "repeat until we see the same calculated checksum twice". regards, tom lane