Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pglogical_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ pglogical_manager_main(Datum main_arg)

/* If the extension is still not installed after retries, exit. */
if (!OidIsValid(extoid))
{
/*
* Mark that we're exiting due to missing extension so the detach
* handler doesn't wake the supervisor. This prevents rapid restart
* cycles for databases that don't have pglogical installed.
*/
MyPGLogicalWorker->skip_supervisor_wakeup = true;
proc_exit(0);
}

StartTransactionCommand();

Expand Down
10 changes: 9 additions & 1 deletion pglogical_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ pglogical_worker_register(PGLogicalWorker *worker)
worker_shm->crashed_at = 0;
worker_shm->proc = NULL;
worker_shm->worker_type = worker->worker_type;
worker_shm->skip_supervisor_wakeup = false;

LWLockRelease(PGLogicalCtx->lock);

Expand Down Expand Up @@ -462,12 +463,19 @@ pglogical_worker_detach(bool crash)
* Worker has finished work, clean up its state from shmem.
* If this was a manager, notify the supervisor so it can restart
* the manager if needed (e.g., if the database still has subscriptions).
*
* However, if skip_supervisor_wakeup is set, the manager is exiting
* because the extension isn't installed in this database. Don't wake
* the supervisor immediately - let it restart on its normal timeout.
* This prevents rapid cycling for databases without pglogical.
*/
if (MyPGLogicalWorker->worker_type == PGLOGICAL_WORKER_MANAGER)
if (MyPGLogicalWorker->worker_type == PGLOGICAL_WORKER_MANAGER &&
!MyPGLogicalWorker->skip_supervisor_wakeup)
PGLogicalCtx->subscriptions_changed = true;

MyPGLogicalWorker->worker_type = PGLOGICAL_WORKER_NONE;
MyPGLogicalWorker->dboid = InvalidOid;
MyPGLogicalWorker->skip_supervisor_wakeup = false;
}

/*
Expand Down
7 changes: 7 additions & 0 deletions pglogical_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ typedef struct PGLogicalWorker {
/* Database id to connect to. */
Oid dboid;

/*
* Set by manager before exiting due to missing extension.
* Prevents supervisor from being woken immediately, avoiding
* rapid restart cycles for databases without pglogical.
*/
bool skip_supervisor_wakeup;

/* Type-specific worker info */
union
{
Expand Down