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 1ls4V8-0006WO-Ci for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Jun 2021 14:20:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ls4V6-00053y-Ut for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Jun 2021 14:20:40 +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 1ls4V6-00050k-N9 for pgsql-hackers@lists.postgresql.org; Sat, 12 Jun 2021 14:20:40 +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 1ls4Ux-0002JM-7R for pgsql-hackers@lists.postgresql.org; Sat, 12 Jun 2021 14:20:37 +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 15CEKO7D2178606; Sat, 12 Jun 2021 10:20:24 -0400 From: Tom Lane To: Andrew Dunstan cc: Michael Paquier , Dilip Kumar , Kyotaro Horiguchi , Robert Haas , Heikki Linnakangas , PostgreSQL Hackers Subject: Re: Race condition in recovery? In-reply-to: References: <20210611.104036.2233408362728572267.horikyota.ntt@gmail.com> <1832766.1623376398@sss.pgh.pa.us> <20210611.151459.1951886846697638472.horikyota.ntt@gmail.com> <1880685.1623422805@sss.pgh.pa.us> <38830da5-ae00-2262-0f0d-e6b25d9df921@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Sat, 12 Jun 2021 09:05:57 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2178604.1623507624.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 12 Jun 2021 10:20:24 -0400 Message-ID: <2178605.1623507624@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrew Dunstan writes: > I have pushed a fix, tested on a replica of fairywren/drongo, This bit seems a bit random: # WAL segment, this is enough to guarantee that the history file was # archived. my $archive_wait_query =3D - "SELECT '$walfile_to_be_archived' <=3D last_archived_wal FROM pg_stat_a= rchiver;"; + "SELECT coalesce('$walfile_to_be_archived' <=3D last_archived_wal, fals= e) " . + "FROM pg_stat_archiver"; $node_standby->poll_query_until('postgres', $archive_wait_query) or die "Timed out while waiting for WAL segment to be archived"; my $last_archived_wal_file =3D $walfile_to_be_archived; I wonder whether that is a workaround for the poll_query_until bug I proposed to fix at [1]. regards, tom lane [1] https://www.postgresql.org/message-id/2130215.1623450521%40sss.pgh.pa.= us