Skip to content

Code cleanup and tests stability #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cluster.pm
Original file line number Diff line number Diff line change
@@ -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))
{
6 changes: 0 additions & 6 deletions src/pglogical_receiver.c
Original file line number Diff line number Diff line change
@@ -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.
34 changes: 22 additions & 12 deletions t/008_bugfixes.pl
Original file line number Diff line number Diff line change
@@ -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,30 +98,35 @@

# 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
WHERE backend_type LIKE 'client backend'
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");