Re: START_REPLICATION SLOT causing a crash in an assert build - Mailing list pgsql-hackers

From Masahiko Sawada
Subject Re: START_REPLICATION SLOT causing a crash in an assert build
Date
Msg-id CAD21AoCPv5GWTOv4QvpNjn55F6Qzqe_Xi=Jq=Nn1hz_88tQnWA@mail.gmail.com
Whole thread Raw
In response to Re: START_REPLICATION SLOT causing a crash in an assert build  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Thu, Oct 20, 2022 at 6:54 AM Andres Freund <andres@anarazel.de> wrote:
>
> Hi,
>
> On 2022-10-13 15:57:28 +0900, Masahiko Sawada wrote:
> > I've attached an updated patch. I've added the common function to
> > start pg_recvlogical and wait for it to become active. Please review
> > it.
>
> > +# Start pg_recvlogical process and wait for it to become active.
> > +sub start_pg_recvlogical
> > +{
> > +     my ($node, $slot_name, $create_slot) = @_;
> > +
> > +     my @cmd = (
> > +             'pg_recvlogical', '-S', "$slot_name", '-d',
> > +             $node->connstr('postgres'),
> > +             '--start', '--no-loop', '-f', '-');
> > +     push @cmd, '--create-slot' if $create_slot;
> > +
> > +     # start pg_recvlogical process.
> > +     my $pg_recvlogical = IPC::Run::start(@cmd);
> > +
> > +     # Wait for the replication slot to become active.
> > +     $node->poll_query_until('postgres',
> > +             "SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = '$slot_name' AND active_pid IS
NOTNULL)"
 
> > +     ) or die "slot never became active";
> > +
> > +     return $pg_recvlogical;
> > +}
>
> Because you never process the output from pg_recvlogical I think this test
> will fail if the pipe buffer is small (or more changes are made). I think
> either it needs to output to a file, or we need to process the output.

Okay, but how can we test this situation? As far as I tested, if we
don't specify the redirection of pg_recvlogical's output as above,
pg_recvlogical's stdout and stderr are output to the log file. So I
could not reproduce the issue you're concerned about. Which pipe do
you refer to?

>
> A file seems the easier solution in this case, we don't really care about what
> changes are streamed to the client, right?
>
>
> > +$node = PostgreSQL::Test::Cluster->new('test2');
> > +$node->init(allows_streaming => 'logical');
> > +$node->start;
> > +$node->safe_psql('postgres', "CREATE TABLE test(i int)");
>
> Why are we creating a new cluster? Initdbs takes a fair bit of time on some
> platforms, so this seems unnecessary?

Agreed.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: parse partition strategy string in gram.y
Next
From: "Drouvot, Bertrand"
Date:
Subject: Re: Patch proposal: make use of regular expressions for the username in pg_hba.conf