Fix the logical replication timeout during large transactions.
authorAmit Kapila <[email protected]>
Wed, 11 May 2022 04:31:35 +0000 (10:01 +0530)
committerAmit Kapila <[email protected]>
Wed, 11 May 2022 04:31:35 +0000 (10:01 +0530)
commita4015ec0375da35e999e86696571ff354a8f706b
treeb6f620c7925b7cb12d95859d7922c86c3d23bb24
parent5951ad124845e1a81d6259e36e75989afff7eabd
Fix the logical replication timeout during large transactions.

The problem is that we don't send keep-alive messages for a long time
while processing large transactions during logical replication where we
don't send any data of such transactions. This can happen when the table
modified in the transaction is not published or because all the changes
got filtered. We do try to send the keep_alive if necessary at the end of
the transaction (via WalSndWriteData()) but by that time the
subscriber-side can timeout and exit.

To fix this we try to send the keepalive message if required after
processing certain threshold of changes.

Reported-by: Fabrice Chapuis
Author: Wang wei and Amit Kapila
Reviewed By: Masahiko Sawada, Euler Taveira, Hou Zhijie, Hayato Kuroda
Backpatch-through: 10
Discussion: https://postgr.es/m/CAA5-nLARN7-3SLU_QUxfy510pmrYK6JJb=bk3hcgemAM_pAv+w@mail.gmail.com
src/backend/replication/logical/logical.c
src/backend/replication/pgoutput/pgoutput.c
src/backend/replication/walsender.c
src/include/replication/logical.h