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 1mW2IO-0000cJ-UC for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Sep 2021 20:04:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mW2IN-0005Z4-Tn for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Sep 2021 20:04:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mW2IM-0005Yw-QH for pgsql-hackers@lists.postgresql.org; Thu, 30 Sep 2021 20:04:43 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mW2IJ-0008EX-W0 for pgsql-hackers@lists.postgresql.org; Thu, 30 Sep 2021 20:04:41 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 52CF75C013F; Thu, 30 Sep 2021 16:04:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 30 Sep 2021 16:04:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=bnGZSjJLfM3BteIWlQG4K5aJStSVUuIGHFc9mPmUgK0=; b=t4Tcc5P6 WXbqCihJ+/dgCs0tH9Xt6Mpk5H27LL+3X2YDDWrBfAvZiZs6qwFfXgtqWfTa978e AlD8AZomLQXTWx1007e4Zy7BpMCpsBQLS3w6tJw6uVOyDqxl00WKZmY04/36sfqV TVrr9V2VLE/NiCf5KETR6ROcvLn6Zx/0tDGKCWkFsC6Ge8i6+IzlnvNL3odl1+x0 99m5+FEcEK9ybjGAkKi2I/bDKzsWudUk22bozsBr4QXz4/g95/yT2R26Ot8cabNH XuKY6rx1lEUybSd+gmOlKfjnCRJBDLy2m7/mxN6kDoY4vTfpFq92XN+ZrF/p6YjI JwK/MNsImCOcbQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekgedgudegvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepteevgeffffegvddvheeileelveeghedvleffgfevvdeh feefheekfeehudelgfdunecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghdphi houhhtuhgsvgdrtghomhdpvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Sep 2021 16:04:37 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 4B3D12A06AB; Thu, 30 Sep 2021 17:04:34 -0300 (-03) Date: Thu, 30 Sep 2021 17:04:34 -0300 From: Alvaro Herrera To: Tom Lane Cc: Andrew Dunstan , "Bossart, Nathan" , Kyotaro Horiguchi , "andres@anarazel.de" , "masao.fujii@oss.nttdata.com" , "pgsql-hackers@lists.postgresql.org" , "mengjuan.cmj@alibaba-inc.com" , "Jakub.Wartak@tomtom.com" , Ryo Matsumura Subject: Re: prevent immature WAL streaming Message-ID: <202109302004.zhg2brcrm42w@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tbhjv4na3rk3rkbw" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3187351.1633028036@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --tbhjv4na3rk3rkbw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2021-Sep-30, Tom Lane wrote: > Just when you thought it was safe to go back in the water: > > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prairiedog&dt=2021-09-29%2022%3A05%3A44 > > which is complaining that the (misspelled, BTW) Ah, the case of the missing juxtaposed consonants. Les Luthiers have something to say on that matter. https://www.youtube.com/watch?v=ptorPqV7D5s > log message 'sucessfully skipped missing contrecord at' doesn't show > up. Hmm. Well, as I said, maybe this part of the test isn't worth much anyway. Rather than spending time trying to figure out why isn't this triggering the WAL overwriting, I compared the coverage report for running only the first test to the coverage report of running only the second test. It turns out that there's no relevant coverage increase in the second test. So I propose just removing that part. (The reason I added that test in the first place was to try to reproduce the problem without having to physically unlink a WAL file from the primary's pg_wal subdir. But maybe it's just make-work.) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ --tbhjv4na3rk3rkbw Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Remove-test-fix-typo.patch" From 759846455920d1886a154b2b159363d353ba0def Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Thu, 30 Sep 2021 16:55:17 -0300 Subject: [PATCH] Remove test, fix typo --- src/backend/access/transam/xlog.c | 2 +- .../recovery/t/026_overwrite_contrecord.pl | 116 +----------------- src/test/recovery/t/idiosyncratic_copy | 20 --- 3 files changed, 3 insertions(+), 135 deletions(-) delete mode 100755 src/test/recovery/t/idiosyncratic_copy diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 1388afdfb0..f8c714b7b7 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -10598,7 +10598,7 @@ VerifyOverwriteContrecord(xl_overwrite_contrecord *xlrec, XLogReaderState *state LSN_FORMAT_ARGS(state->overwrittenRecPtr)); ereport(LOG, - (errmsg("sucessfully skipped missing contrecord at %X/%X, overwritten at %s", + (errmsg("successfully skipped missing contrecord at %X/%X, overwritten at %s", LSN_FORMAT_ARGS(xlrec->overwritten_lsn), timestamptz_to_str(xlrec->overwrite_time)))); diff --git a/src/test/recovery/t/026_overwrite_contrecord.pl b/src/test/recovery/t/026_overwrite_contrecord.pl index acf9bd08d1..1725a97531 100644 --- a/src/test/recovery/t/026_overwrite_contrecord.pl +++ b/src/test/recovery/t/026_overwrite_contrecord.pl @@ -10,7 +10,7 @@ use PostgresNode; use TestLib; use Test::More; -plan tests => 5; +plan tests => 3; # Test: Create a physical replica that's missing the last WAL file, # then restart the primary to create a divergent WAL file and observe @@ -89,120 +89,8 @@ ok($node_standby->safe_psql('postgres', 'select * from foo') eq 'hello', my $log = slurp_file($node_standby->logfile); like( $log, - qr[sucessfully skipped missing contrecord at], + qr[successfully skipped missing contrecord at], "found log line in standby"); $node->stop; $node_standby->stop; - - -# Second test: a standby that receives WAL via archive/restore commands. -$node = PostgresNode->new('primary2'); -$node->init( - has_archiving => 1, - extra => ['--wal-segsize=1']); -$node->set_replication_conf; - -# Note: consistent use of forward slashes here avoids any escaping problems -# that arise from use of backslashes. That means we need to double-quote all -# the paths in the archive_command -my $perlbin = TestLib::perl2host($^X); -$perlbin =~ s!\\!/!g if $TestLib::windows_os; -my $archivedir = $node->archive_dir; -$archivedir =~ s!\\!/!g if $TestLib::windows_os; -$node->append_conf( - 'postgresql.conf', - qq{ -archive_command = '"$perlbin" "$FindBin::RealBin/idiosyncratic_copy" "%p" "$archivedir/%f"' -wal_level = replica -max_wal_senders = 2 -wal_keep_size = 1GB -}); -# Make sure that Msys perl doesn't complain about difficulty in setting locale -# when called from the archive_command. -local $ENV{PERL_BADLANG} = 0; -$node->start; -$node->backup('backup'); - -$node_standby = PostgresNode->new('standby2'); -$node_standby->init_from_backup($node, 'backup', has_restoring => 1); - -$node_standby->start; - -$node->safe_psql('postgres', 'create table filler (a int)'); -# First, measure how many bytes does the insertion of 1000 rows produce -$start_lsn = - $node->safe_psql('postgres', q{select pg_current_wal_insert_lsn() - '0/0'}); -$node->safe_psql('postgres', - 'insert into filler select * from generate_series(1, 1000)'); -$end_lsn = - $node->safe_psql('postgres', q{select pg_current_wal_insert_lsn() - '0/0'}); -$rows_walsize = $end_lsn - $start_lsn; - -# Now consume all remaining room in the current WAL segment, leaving -# space enough only for the start of a largish record. -$node->safe_psql( - 'postgres', qq{ -WITH setting AS ( - SELECT setting::int AS wal_segsize - FROM pg_settings WHERE name = 'wal_segment_size' -) -INSERT INTO filler -SELECT g FROM setting, - generate_series(1, 1000 * (wal_segsize - ((pg_current_wal_insert_lsn() - '0/0') % wal_segsize)) / $rows_walsize) g -}); - -# Now block idiosyncratic_copy from creating the next WAL in the replica -my $archivedgood = $node->safe_psql('postgres', - q{SELECT pg_walfile_name(pg_current_wal_insert_lsn())}); -my $archivedfail = $node->safe_psql( - 'postgres', - q{SELECT pg_walfile_name(pg_current_wal_insert_lsn() + setting::integer) - from pg_settings where name = 'wal_segment_size'}); -open my $filefail, ">", "$archivedir/$archivedfail.fail" - or die "can't open $archivedir/$archivedfail.fail: $!"; - -my $currlsn = - $node->safe_psql('postgres', 'select pg_current_wal_insert_lsn() - 1000'); - -# Now produce a large WAL record in a transaction that we leave open -my ($in, $out); -my $timer = IPC::Run::timeout(180); -my $h = - $node->background_psql('postgres', \$in, \$out, $timer, on_error_stop => 0); - -$in .= qq{BEGIN; -SELECT pg_logical_emit_message(true, 'test 026', repeat('somenoise', 8192)); -}; -$h->pump_nb; -$node->poll_query_until( - 'postgres', - "SELECT last_archived_wal >= '$archivedgood' FROM pg_stat_archiver"), - or die "Timed out while waiting for standby to catch up"; - -# Now crash the node with the transaction open -$node->stop('immediate'); -$h->finish(); -$node->start; -$node->safe_psql('postgres', 'create table witness (a int);'); -$node->safe_psql('postgres', 'insert into witness values (42)'); -unlink "$archivedir/$archivedfail.fail" - or die "can't unlink $archivedir/$archivedfail.fail: $!"; -$node->safe_psql('postgres', 'select pg_switch_wal()'); - -$until_lsn = $node->safe_psql('postgres', "SELECT pg_current_wal_lsn()"); -$caughtup_query = "SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_lsn()"; -$node_standby->poll_query_until('postgres', $caughtup_query) - or die "Timed out while waiting for standby to catch up"; - -my $answer = $node_standby->safe_psql('postgres', 'select * from witness'); -is($answer, '42', 'witness tuple appears'); - -# Verify message appears in standby's log -$log = slurp_file($node_standby->logfile); -like( - $log, - qr[sucessfully skipped missing contrecord at], - "found log line in standby"); -$node->stop; -$node_standby->stop; diff --git a/src/test/recovery/t/idiosyncratic_copy b/src/test/recovery/t/idiosyncratic_copy deleted file mode 100755 index 83e25e0e89..0000000000 --- a/src/test/recovery/t/idiosyncratic_copy +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use File::Copy; - -die "wrong number of arguments" if @ARGV != 2; -my ($source, $target) = @ARGV; -if ($^O eq 'msys') -{ - # make a windows path look like an msys path if necessary - $source =~ s!^([A-Za-z]):!'/' . lc($1)!e; - $source =~ s!\\!/!g; -} - -die "$0: failed copy of $target" if -f "$target.fail"; - -copy($source, $target) or die "couldn't copy $source to $target: $!"; -print STDERR "$0: archived $source to $target successfully\n"; -- 2.30.2 --tbhjv4na3rk3rkbw--