v4-0009-fixup-get-rid-of-is_schema_sent-entirely.patch

application/octet-stream

Filename: v4-0009-fixup-get-rid-of-is_schema_sent-entirely.patch
Type: application/octet-stream
Part: 8
Message: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v4-0009
Subject: fixup: get rid of is_schema_sent entirely
File+
src/backend/replication/logical/reorderbuffer.c 2 24
src/include/replication/reorderbuffer.h 0 5
From 1f6b7447ac3d80fc47a603d106b2d26bfc46c710 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@2ndquadrant.com>
Date: Fri, 27 Dec 2019 23:46:15 +0100
Subject: [PATCH v4 09/19] fixup: get rid of is_schema_sent entirely

We'll do this in the pgoutput.c code directly, not in reorderbuffer.
---
 src/backend/replication/logical/reorderbuffer.c | 26 ++-----------------------
 src/include/replication/reorderbuffer.h         |  5 -----
 2 files changed, 2 insertions(+), 29 deletions(-)

diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 78b5c00..dda651e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2229,7 +2229,6 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
 					 * about the message itself?
 					 */
 					LocalExecuteInvalidationMessage(&change->data.inval.msg);
-					txn->is_schema_sent = false;
 					break;
 
 				case REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID:
@@ -2728,9 +2727,6 @@ ReorderBufferExecuteInvalidations(ReorderBuffer *rb, ReorderBufferTXN *txn)
 
 	for (i = 0; i < txn->ninvalidations; i++)
 		LocalExecuteInvalidationMessage(&txn->invalidations[i]);
-
-	/* Invalidate current schema as well */
-	txn->is_schema_sent = false;
 }
 
 /*
@@ -2747,21 +2743,11 @@ ReorderBufferXidSetCatalogChanges(ReorderBuffer *rb, TransactionId xid,
 	txn->txn_flags |= RBTXN_HAS_CATALOG_CHANGES;
 
 	/*
-	 * We read catalog changes from WAL, which are not yet sent, so
-	 * invalidate current schema in order output plugin can resend
-	 * schema again.
-	 */
-	txn->is_schema_sent = false;
-
-	/*
 	 * TOCHECK: Mark toplevel transaction as having catalog changes too
 	 * if one of its children has.
 	 */
 	if (txn->toptxn != NULL)
-	{
 		txn->toptxn->txn_flags |= RBTXN_HAS_CATALOG_CHANGES;
-		txn->toptxn->is_schema_sent = false;
-	}
 }
 
 /*
@@ -3344,9 +3330,8 @@ ReorderBufferStreamTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 		 * TOCHECK: We have to rebuild historic snapshot to be sure it includes all
 		 * information about subtransactions, which could arrive after streaming start.
 		 */
-		if (!txn->is_schema_sent)
-			snapshot_now = ReorderBufferCopySnap(rb, txn->base_snapshot,
-												 txn, command_id);
+		snapshot_now = ReorderBufferCopySnap(rb, txn->base_snapshot,
+											 txn, command_id);
 	}
 
 	/*
@@ -3601,12 +3586,6 @@ ReorderBufferStreamTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 						snapshot_now = change->data.snapshot;
 					}
 
-					/*
-					 * TOCHECK: Snapshot changed, then invalidate current schema to reflect
-					 * possible catalog changes.
-					 */
-					txn->is_schema_sent = false;
-
 					/* and continue with the new one */
 					SetupHistoricSnapshot(snapshot_now, txn->tuplecid_hash,
 										  txn->xid);
@@ -3645,7 +3624,6 @@ ReorderBufferStreamTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 					 * about the message itself?
 					 */
 					LocalExecuteInvalidationMessage(&change->data.inval.msg);
-					txn->is_schema_sent = false;
 					break;
 
 				case REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID:
diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h
index 7d08e2f..e2b8db0 100644
--- a/src/include/replication/reorderbuffer.h
+++ b/src/include/replication/reorderbuffer.h
@@ -237,11 +237,6 @@ typedef struct ReorderBufferTXN
 	XLogRecPtr	final_lsn;
 
 	/*
-	 * Do we need to send schema for this transaction in output plugin?
-	 */
-	bool		is_schema_sent;
-
-	/*
 	 * Toplevel transaction for this subxact (NULL for top-level).
 	 */
 	struct ReorderBufferTXN *toptxn;
-- 
1.8.3.1