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

Поиск
Список
Период
Сортировка
От Dewei Dai
Тема Re:Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication
Дата
Msg-id 1adfcc25.1704.19bac75597f.Coremail.daidewei1970@163.com
обсуждение исходный текст
Ответ на Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication  (Fujii Masao <masao.fujii@gmail.com>)
Список pgsql-hackers
Hi Fujii,
At 2026-01-11 17:21:19, "Fujii Masao" <masao.fujii@gmail.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;`

В списке pgsql-hackers по дате отправления: