From 9913c9c37af252ff062baaecab73830800d3f5a0 Mon Sep 17 00:00:00 2001 From: Ajin Cherian Date: Wed, 3 Mar 2021 05:33:01 -0500 Subject: [PATCH v47] 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 9e0c2dc..ad537f4 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -2323,6 +2323,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 always handling a message (which maybe the apply + * worker could have handled). + */ + process_syncing_tables(last_received); + } + /* * Init the ApplyMessageContext which we clean up after each replication * protocol message. -- 1.8.3.1