From e278bae535ceeea1b0ab1d0a87e8295193193740 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 17 Sep 2026 02:01:58 +0530 Subject: [PATCH v1] Clean up pgoutput schema cache after prepared transactions Streamed transactions remember which relation schemas were sent until their final outcome. Ordinary stream commit and abort remove those transaction IDs, but COMMIT PREPARED and ROLLBACK PREPARED did not. Consequently, long-lived walsenders retained an entry for every touched relation and finished prepared transaction. Clean up the relation schema cache after sending the final prepared- transaction message, using the same commit or abort semantics as ordinary streamed transactions. --- src/backend/replication/pgoutput/pgoutput.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 484ffbe2cee..dd3bb80f822 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -701,6 +701,9 @@ pgoutput_commit_prepared_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, OutputPluginPrepareWrite(ctx, true); logicalrep_write_commit_prepared(ctx->out, txn, commit_lsn); OutputPluginWrite(ctx, true); + + if (rbtxn_is_streamed(txn)) + cleanup_rel_sync_cache(txn->xid, true); } /* @@ -718,6 +721,9 @@ pgoutput_rollback_prepared_txn(LogicalDecodingContext *ctx, logicalrep_write_rollback_prepared(ctx->out, txn, prepare_end_lsn, prepare_time); OutputPluginWrite(ctx, true); + + if (rbtxn_is_streamed(txn)) + cleanup_rel_sync_cache(txn->xid, false); } /* -- 2.34.1