Skip to content

Instantly share code, notes, and snippets.

@pstef
Last active August 7, 2017 06:44
Show Gist options
  • Save pstef/0922cb74750545c3cf48cdf030e06cd8 to your computer and use it in GitHub Desktop.
Save pstef/0922cb74750545c3cf48cdf030e06cd8 to your computer and use it in GitHub Desktop.
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index bfa8499..fc9221b 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -287,6 +287,14 @@ void
InitProcess(void)
{
PGPROC *volatile *procgloballist;
+#define LIST_TYPE_ENTRY(e) [(e)] = (#e)
+ enum listType { autovac, bgworker, backend } which;
+ char const * const listTypeNames[] = {
+ LIST_TYPE_ENTRY(autovac),
+ LIST_TYPE_ENTRY(bgworker),
+ LIST_TYPE_ENTRY(backend)
+ };
+#undef LIST_TYPE_ENTRY
/*
* ProcGlobal should be set up already (if we are a backend, we inherit
@@ -300,11 +308,11 @@ InitProcess(void)
/* Decide which list should supply our PGPROC. */
if (IsAnyAutoVacuumProcess())
- procgloballist = &ProcGlobal->autovacFreeProcs;
+ which = autovac, procgloballist = &ProcGlobal->autovacFreeProcs;
else if (IsBackgroundWorker)
- procgloballist = &ProcGlobal->bgworkerFreeProcs;
+ which = bgworker, procgloballist = &ProcGlobal->bgworkerFreeProcs;
else
- procgloballist = &ProcGlobal->freeProcs;
+ which = backend, procgloballist = &ProcGlobal->freeProcs;
/*
* Try to get a proc struct from the appropriate free list. If this
@@ -329,13 +337,12 @@ InitProcess(void)
/*
* If we reach here, all the PGPROCs are in use. This is one of the
* possible places to detect "too many backends", so give the standard
- * error message. XXX do we need to give a different failure message
- * in the autovacuum case?
+ * error message.
*/
SpinLockRelease(ProcStructLock);
ereport(FATAL,
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
- errmsg("sorry, too many clients already")));
+ errmsg("%s proc list saturated", listTypeNames[which])));
}
MyPgXact = &ProcGlobal->allPgXact[MyProc->pgprocno];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment