]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove the streaming files for incomplete xacts after restart.
authorAmit Kapila <akapila@postgresql.org>
Sat, 7 Jan 2023 06:34:33 +0000 (12:04 +0530)
committerAmit Kapila <akapila@postgresql.org>
Sat, 7 Jan 2023 06:34:33 +0000 (12:04 +0530)
After restart, we try to stream the changes for large transactions that
were not sent before server crash and restart. However, we forget to send
the abort message for such transactions. This leads to spurious streaming
files on the subscriber which won't be cleaned till the apply worker or
the subscriber server restarts.

Reported-by: Dilip Kumar
Author: Hou Zhijie
Reviewed-by: Dilip Kumar and Amit Kapila
Backpatch-through: 14
Discussion: https://postgr.es/m/OS0PR01MB5716A773F46768A1B75BE24394FB9@OS0PR01MB5716.jpnprd01.prod.outlook.com

src/backend/replication/logical/reorderbuffer.c

index c07d25903cddda1f7d18dd638071b6759a120c42..e3b67e4447a5a9b882b2fa9c67d32d80363b68ac 100644 (file)
@@ -2905,6 +2905,10 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
                {
                        elog(DEBUG2, "aborting old transaction %u", txn->xid);
 
+                       /* Notify the remote node about the crash/immediate restart. */
+                       if (rbtxn_is_streamed(txn))
+                               rb->stream_abort(rb, txn, InvalidXLogRecPtr);
+
                        /* remove potential on-disk data, and deallocate this tx */
                        ReorderBufferCleanupTXN(rb, txn);
                }