Skip to content

Commit eee6cf1

Browse files
committed
When a bgworker exits, always call ReleasePostmasterChildSlot.
Commit e2ce9aa was insufficiently well thought out. Repair.
1 parent 970d1f7 commit eee6cf1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,23 +2856,25 @@ CleanupBackgroundWorker(int pid,
28562856
* backend, any exit status other than 0 or 1 is considered a crash
28572857
* and causes a system-wide restart.
28582858
*/
2859-
if (rw->rw_worker.bgw_flags & BGWORKER_SHMEM_ACCESS)
2859+
if ((rw->rw_worker.bgw_flags & BGWORKER_SHMEM_ACCESS) != 0)
28602860
{
28612861
if (!EXIT_STATUS_0(exitstatus) && !EXIT_STATUS_1(exitstatus))
28622862
{
28632863
HandleChildCrash(pid, exitstatus, namebuf);
28642864
return true;
28652865
}
2866+
}
28662867

2867-
if (!ReleasePostmasterChildSlot(rw->rw_child_slot))
2868-
{
2869-
/*
2870-
* Uh-oh, the child failed to clean itself up. Treat as a
2871-
* crash after all.
2872-
*/
2873-
HandleChildCrash(pid, exitstatus, namebuf);
2874-
return true;
2875-
}
2868+
/*
2869+
* We must release the postmaster child slot whether this worker
2870+
* is connected to shared memory or not, but we only treat it as
2871+
* a crash if it is in fact connected.
2872+
*/
2873+
if (!ReleasePostmasterChildSlot(rw->rw_child_slot) &&
2874+
(rw->rw_worker.bgw_flags & BGWORKER_SHMEM_ACCESS) != 0)
2875+
{
2876+
HandleChildCrash(pid, exitstatus, namebuf);
2877+
return true;
28762878
}
28772879

28782880
/* Get it out of the BackendList and clear out remaining data */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy