logical replication: patch to ensure timely cleanup of aborted transactions in ReorderBuffer

Started by Vaijayanti Bharadwajalmost 2 years ago2 messageshackers

Thread notes

1 note#bug
hackorum-bot#bug
hackorum-bot
1 day ago

@global #bug

#bug
Jump to latest
#1Vaijayanti Bharadwaj
vaijayanti.bharadwaj@enterprisedb.com

Hello,

This patch is a proposed fix for an issue that can occur in logical
replication where:
1. streaming of transactions is disabled.
2. First, say there is a transaction that's PREPAREd. This prepared
transaction is not resolved for some time. It holds back the
oldestRunningXid.
3. Large transactions with xid higher than that of the prepared transaction
spill to disk as they are decoded in the ReorderBuffer.
4. There is an unclean shutdown due to which the large transactions get
aborted. But there is no explicit abort record.
5. On startup, the ReorderBuffer continues to decode and hold the aborted
transactions and they continue to accumulate as spill files.
6. Once the prepared transaction is resolved, these transactions will be
cleaned up, but if there is a delay, the aborted transactions could hold up
considerable space.
(A customer had run into this issue at EDB)

0001: is a TAP test that reproduces this and tests for this. It fails
without this and passes with it.
0002: is the patch that fixes this issue.

Thanks,
Vaijayanti

Attachments:

t50694_1
0001-TAP-test-that-passes-with-the-ReorderBuffer-cleanup-.patchapplication/octet-stream; name=0001-TAP-test-that-passes-with-the-ReorderBuffer-cleanup-.patchDownload+118-1
0002-cleanup-incomplete-transactions-on-startup-in-Reorde.patchapplication/octet-stream; name=0002-cleanup-incomplete-transactions-on-startup-in-Reorde.patchDownload+79-2
#2Ashutosh Bapat
ashutosh.bapat.oss@gmail.com
In reply to: Vaijayanti Bharadwaj (#1)
Re: logical replication: patch to ensure timely cleanup of aborted transactions in ReorderBuffer

Hi Vaijayanti,

On Fri, Dec 6, 2024 at 2:50 PM Vaijayanti Bharadwaj
<vaijayanti.bharadwaj@enterprisedb.com> wrote:

Hello,

This patch is a proposed fix for an issue that can occur in logical replication where:
1. streaming of transactions is disabled.
2. First, say there is a transaction that's PREPAREd. This prepared transaction is not resolved for some time. It holds back the oldestRunningXid.
3. Large transactions with xid higher than that of the prepared transaction spill to disk as they are decoded in the ReorderBuffer.
4. There is an unclean shutdown due to which the large transactions get aborted. But there is no explicit abort record.
5. On startup, the ReorderBuffer continues to decode and hold the aborted transactions and they continue to accumulate as spill files.
6. Once the prepared transaction is resolved, these transactions will be cleaned up, but if there is a delay, the aborted transactions could hold up considerable space.
(A customer had run into this issue at EDB)

0001: is a TAP test that reproduces this and tests for this. It fails without this and passes with it.
0002: is the patch that fixes this issue.

A similar problem was discussed at [1]/messages/by-id/CAD21AoDht9Pz_DFv_R2LqBTBbO4eGrpa9Vojmt5z5sEx3XwD7A@mail.gmail.com. That thread seems to have
halted without a commit. Can you please check if the solution there
works for you? If so review the patch and help move the thread ahead.

[1]: /messages/by-id/CAD21AoDht9Pz_DFv_R2LqBTBbO4eGrpa9Vojmt5z5sEx3XwD7A@mail.gmail.com

--
Best Wishes,
Ashutosh Bapat