Since commit 4daa140a2f50 adds the INTERNAL_SPEC_ABORT change, I think it's no
longer necessary to care about "pending speculations" at the time we receive
the next INTERNAL_SPEC_INSERT change.

-- 
Antonin Houska
Web: https://www.cybertec-postgresql.com

>From 06066f5376384d88c638fa4c9f7bf860a0857145 Mon Sep 17 00:00:00 2001
From: Antonin Houska <[email protected]>
Date: Thu, 5 Mar 2026 08:40:16 +0100
Subject: [PATCH] Remove cleanup of speculative insert.

Commit 4daa140a2f50 introduces decoding of speculative insert aborts, so we
should not see pending speculation when decoding a new one.
---
 src/backend/replication/logical/reorderbuffer.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index e832fa0d8ea..8ab1625d33e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2446,12 +2446,8 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
 					 * CheckTableNotInUse() and locking.
 					 */
 
-					/* clear out a pending (and thus failed) speculation */
-					if (specinsert != NULL)
-					{
-						ReorderBufferFreeChange(rb, specinsert, true);
-						specinsert = NULL;
-					}
+					/* previous speculation should have been aborted */
+					Assert(specinsert == NULL);
 
 					/* and memorize the pending insertion */
 					dlist_delete(&change->node);
-- 
2.47.3

Reply via email to