From 78d7b8c62bfc60dc7a04a3128a4488eb2e39c2e6 Mon Sep 17 00:00:00 2001 From: Alexey Kondratov Date: Thu, 15 Apr 2021 13:31:17 +0300 Subject: [PATCH 1/3] Remove unnecessary MessageContext creation. Code cleanup after merge of PGPRO-3253. --- src/pglogical_receiver.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pglogical_receiver.c b/src/pglogical_receiver.c index f05617a716..4a34c7c5db 100644 --- a/src/pglogical_receiver.c +++ b/src/pglogical_receiver.c @@ -719,12 +719,6 @@ pglogical_receiver_main(Datum main_arg) /* Create new slot if needed */ query = createPQExpBuffer(); - /* TODO: remove this once we rebase onto fresh version of EE which - * doesn't use MessageContext inside planner guts (PGPRO-3253)*/ - MessageContext = AllocSetContextCreate(TopMemoryContext, - "MessageContext", - ALLOCSET_DEFAULT_SIZES); - /* * Make sure config is up to date as we are going to check out * backup_node_id; if it has been cleared we must be aware of that. From e393be8a1ed84898d2a91231388ab285cbda786d Mon Sep 17 00:00:00 2001 From: Alexey Kondratov Date: Thu, 15 Apr 2021 13:36:57 +0300 Subject: [PATCH 2/3] Improve sability of 008_bugfixes.pl test. Also make free port choosing routine work on BSD-like systems (e.g. macOS). --- Cluster.pm | 4 ++-- t/008_bugfixes.pl | 34 ++++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Cluster.pm b/Cluster.pm index b2eaab6313..ec9164b4df 100644 --- a/Cluster.pm +++ b/Cluster.pm @@ -32,7 +32,7 @@ sub mm_get_free_port { # advance $port, wrapping correctly around range end - $port = 26000 if ++$port == 27000; + $port = 26000 if ++$port >= 27000; print "# Checking port $port\n"; # Check first that candidate port number is not included in @@ -58,7 +58,7 @@ sub mm_get_free_port if ($found == 1) { foreach my $addr (qw(127.0.0.1), - $PostgresNode::use_tcp ? qw(127.0.0.2 127.0.0.3 0.0.0.0) : ()) + $PostgresNode::use_tcp && ($^O eq "linux" || $windows_os) ? qw(127.0.0.2 127.0.0.3 0.0.0.0) : ()) { if (!PostgresNode::can_bind($addr, $port)) { diff --git a/t/008_bugfixes.pl b/t/008_bugfixes.pl index 25c1bd2a17..21824abc47 100644 --- a/t/008_bugfixes.pl +++ b/t/008_bugfixes.pl @@ -1,10 +1,15 @@ +use Carp; +use POSIX; use strict; +use Test::More; +use TestLib; +use Time::HiRes qw(usleep); use warnings; -use Carp; + use PostgresNode; use Cluster; -use TestLib; -use Test::More; + +use Test::More tests => Cluster::is_ee() ? 6 : 5; my $cluster = new Cluster(3); $cluster->init(); @@ -42,7 +47,7 @@ $hash2 = $cluster->safe_psql(2, $hash_query); note("$hash0, $hash1, $hash2"); is( (($hash0 eq $hash1) and ($hash1 eq $hash2)) , 1, - "Check that hash is the same after query"); + "Check that hash is the same after query"); } $cluster->safe_psql(0, q{ @@ -72,7 +77,7 @@ $hash2 = $cluster->safe_psql(2, $hash_query); note("$hash0, $hash1, $hash2"); is( (($hash0 eq $hash1) and ($hash1 eq $hash2)) , 1, - "Check that hash is the same after query"); + "Check that hash is the same after query"); # ############################################################################## # @@ -93,11 +98,13 @@ # Simulate payload $cluster->pgbench(0, ('-i', '-n', -s => '1') ); -my $pgb1 = $cluster->pgbench_async(0, ('-n', -T => '15', -j=>'5', -c => '5') ); -sleep(5); +note( strftime('%Y-%m-%d %H:%M:%S', localtime) . ": starting async pgbench" ); +my $pgb1 = $cluster->pgbench_async(0, ('-n', -T => '25', -j => '1', -c => '5') ); my $pid0; my $attempts = 0; + +note( strftime('%Y-%m-%d %H:%M:%S', localtime) . ": starting polling of backend pid" ); while (1) { $pid0 = $cluster->safe_psql(0, "SELECT pid FROM pg_stat_activity @@ -105,18 +112,21 @@ AND query LIKE 'UPDATE%' LIMIT 1;"); # bf says we might be really unlucky to find no backend doing update - if ($pid0 ne "") + # It does not make much sense to try longer than pgbench run lasts, + # since we need an active backend to kill. So let it be 25 seconds + # both for pgbench_async() and this pg_stat_activity polling. + if ( ($pid0 ne "") || $attempts >= 25*10 ) { last; } + # Wait 0.1 second before retrying. usleep(100_000); $attempts++; - if ($attempts >= 180*10) - { - croak 'failed to fetch backend pid'; - } } +note( strftime('%Y-%m-%d %H:%M:%S', localtime) . ": finished polling of backend pid" ); +is( ($pid0 ne ""), 1, + "found an active backend doing UPDATE" ); # Simulate hard crash note("Simulate hard crash of a backend by SIGKILL to $pid0"); From 7cc27c7daf560c18b87b4c9d77e5f777e862f85e Mon Sep 17 00:00:00 2001 From: arssher Date: Fri, 16 Apr 2021 06:15:08 +0300 Subject: [PATCH 3/3] Allow 65432 range back again. --- Cluster.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cluster.pm b/Cluster.pm index ec9164b4df..b2c7d11583 100644 --- a/Cluster.pm +++ b/Cluster.pm @@ -32,7 +32,7 @@ sub mm_get_free_port { # advance $port, wrapping correctly around range end - $port = 26000 if ++$port >= 27000; + $port = 26000 if ++$port == 27000; print "# Checking port $port\n"; # Check first that candidate port number is not included in