From 22525a226c54b871716a32d8be7caf794a9ae0bb Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 19 Jan 2024 11:54:56 +1100 Subject: [PATCH v1] POC - disable subscription for bad connections --- src/backend/replication/logical/worker.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 911835c..2f7ef4f 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -4516,9 +4516,22 @@ run_apply_worker() MySubscription->name, &err); if (LogRepWorkerWalRcvConn == NULL) - ereport(ERROR, - (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("could not connect to the publisher: %s", err))); + { + PG_TRY(); + { + ereport(ERROR, + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("could not connect to the publisher: %s", err))); + } + PG_CATCH(); + { + if (MySubscription->disableonerr) + DisableSubscriptionAndExit(); + + PG_RE_THROW(); + } + PG_END_TRY(); + } /* * We don't really use the output identify_system for anything but it does -- 1.8.3.1