From 08815e4107e6104d55694bb75b5410e592007b76 Mon Sep 17 00:00:00 2001 From: Hou Zhijie Date: Thu, 5 Jan 2023 18:53:17 +0800 Subject: [PATCH] fix stream changes for crashed transaction We do not send end-of-stream messages for transactions aborted due to crashes, which would result in the stream file being left on the subscriber and not cleaned unless the apply worker is restarted. Fix this by sending a stream abort message when cleaning up a transaction that was aborted by a crash and was previously streamed. --- src/backend/replication/logical/reorderbuffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 66fb039..3cb4cb3 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -2939,6 +2939,10 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid) { elog(DEBUG2, "aborting old transaction %u", txn->xid); + /* Notify the remote node about the crash. */ + if (rbtxn_is_streamed(txn)) + rb->stream_abort(rb, txn, InvalidXLogRecPtr); + /* remove potential on-disk data, and deallocate this tx */ ReorderBufferCleanupTXN(rb, txn); } -- 2.7.2.windows.1