Re:Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication

From: "Dewei Dai" <daidewei1970(at)163(dot)com>
To: "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com>
Cc: "Mircea Cadariu" <cadariu(dot)mircea(at)gmail(dot)com>, "PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re:Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication
Date: 2026-01-11 09:48:50
Message-ID: 1adfcc25.1704.19bac75597f.Coremail.daidewei1970@163.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Fujii,
At 2026-01-11 17:21:19, "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com> wrote:
>That's possible. But TBH I'm not sure how much effort is justified here.
>The test uses pg_recvlogical to activate the slot and doesn't really test
>pg_recvlogical itself. It's unclear how valuable it is to additionally run
>this test on Windows...

>
I applied the V4 patch and tested it on a CentOS 7 x86_64 platform. The test steps are as follows:

1. Create a table:

`create table test_id(id integer);`

2. Create a function to close the connection:

`create or replace function test_f(id integer) returns integer as $$

declare

var1 integer;

begin

SELECT active_pid into var1 FROM pg_replication_slots WHERE slot_name = 'reconnect_test';

perform pg_terminate_backend(var1);

return 1;

end; $$ language plpgsql;`

3. Execute the command to receive logs:

`./pg_recvlogical --create-slot --slot reconnect_test --dbname postgres --start --file decoding.out --fsync-interval 200 --status-interval 100 --verbose`

4. Execute the following shell script:

`while true

do

./psql -d postgres<<EOF

select test_f(1);

\q

EOF

done`

5. Execute data insertion using psql:

`insert into test_id values(1);

insert into test_id values(2);`

6. `tail -f decoding.out`

I found duplicate insert statements in the file.

I don't know if this is a problem.
Additionally, I tried moving the two lines involving `Stream LogicalLog` outside the loop
in the `main` function, and then it worked correctly.
`output_written_lsn = InvalidXLogRecPtr;`
`output_fsync_lsn = InvalidXLogRecPtr;`

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Huanbing Lu 2026-01-11 09:51:54 Re: SQL Property Graph Queries (SQL/PGQ)
Previous Message Tatsuya Kawata 2026-01-11 09:21:07 Re: [Patch]Add tab completion for DELETE ... USING