From 15d4f86a7965643de86be3ba52fddda0603427a8 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Aug 2021 13:07:30 +1000 Subject: [PATCH v2] 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 295b1e0..945c4e2 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -2552,6 +2552,16 @@ LogicalRepApplyLoop(XLogRecPtr last_received) TimeLineID tli; ErrorContextCallback errcallback; + 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