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

From Andres Freund
Subject Re: START_REPLICATION SLOT causing a crash in an assert build
Date
Msg-id 20221019215421.cr2t7w4oimfoedfr@awork3.anarazel.de
Whole thread Raw
In response to Re: START_REPLICATION SLOT causing a crash in an assert build  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses Re: START_REPLICATION SLOT causing a crash in an assert build  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
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 NOT
NULL)"
> +    ) 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.

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?

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: pg_recvlogical prints bogus error when interrupted
Next
From: Peter Geoghegan
Date:
Subject: Decoupling antiwraparound autovacuum from special rules around auto cancellation