aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-05-07 16:30:23 -0400
committerRobert Haas <rhaas@postgresql.org>2014-05-07 16:30:23 -0400
commiteee6cf1f337aa488a20e9111df446cdad770e645 (patch)
treee70c1c3c066ab82df9242efca0e118e79a3859a5 /src
parent970d1f76d1600dfbdbd9cd88a9e2af113e253798 (diff)
downloadpostgresql-eee6cf1f337aa488a20e9111df446cdad770e645.tar.gz
postgresql-eee6cf1f337aa488a20e9111df446cdad770e645.zip
When a bgworker exits, always call ReleasePostmasterChildSlot.
Commit e2ce9aa27bf20eff2d991d0267a15ea5f7024cd7 was insufficiently well thought out. Repair.
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/postmaster.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index ec1a59d061a..79d1c506cc3 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -2856,23 +2856,25 @@ CleanupBackgroundWorker(int pid,
* backend, any exit status other than 0 or 1 is considered a crash
* and causes a system-wide restart.
*/
- if (rw->rw_worker.bgw_flags & BGWORKER_SHMEM_ACCESS)
+ if ((rw->rw_worker.bgw_flags & BGWORKER_SHMEM_ACCESS) != 0)
{
if (!EXIT_STATUS_0(exitstatus) && !EXIT_STATUS_1(exitstatus))
{
HandleChildCrash(pid, exitstatus, namebuf);
return true;
}
+ }
- if (!ReleasePostmasterChildSlot(rw->rw_child_slot))
- {
- /*
- * Uh-oh, the child failed to clean itself up. Treat as a
- * crash after all.
- */
- HandleChildCrash(pid, exitstatus, namebuf);
- return true;
- }
+ /*
+ * We must release the postmaster child slot whether this worker
+ * is connected to shared memory or not, but we only treat it as
+ * a crash if it is in fact connected.
+ */
+ if (!ReleasePostmasterChildSlot(rw->rw_child_slot) &&
+ (rw->rw_worker.bgw_flags & BGWORKER_SHMEM_ACCESS) != 0)
+ {
+ HandleChildCrash(pid, exitstatus, namebuf);
+ return true;
}
/* Get it out of the BackendList and clear out remaining data */