v43-0006-Tablesync-early-exit.patch

application/octet-stream

Filename: v43-0006-Tablesync-early-exit.patch
Type: application/octet-stream
Part: 5
Message: Re: [HACKERS] logical decoding of two-phase transactions

Patch

Format: format-patch
Series: patch v43-0006
Subject: Tablesync early exit.
File+
src/backend/replication/logical/worker.c 10 0
From 7a1c7795f4276541d5062a6ecd7d55ade9f117ee Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Sun, 21 Feb 2021 08:12:27 +1100
Subject: [PATCH v43] Tablesync early exit.

Give the tablesync worker an opportunity to see if it can exit immediately
(because it has already caught-up) without it needing to process a message
first before discovering that.
---
 src/backend/replication/logical/worker.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 24e49f0..b80bf69 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -2407,6 +2407,16 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
 	bool		ping_sent = false;
 	TimeLineID	tli;
 
+	if (am_tablesync_worker())
+	{
+		/* 
+		 * Give the tablesync worker an opportunity see if it can immediately
+		 * exit, instead of handling a message (which the apply worker could
+		 * handle) before discovering that.
+		 */
+		process_syncing_tables(last_received);
+	}
+
 	/*
 	 * Init the ApplyMessageContext which we clean up after each replication
 	 * protocol message.
-- 
1.8.3.1