Skip to content

Commit acac35a

Browse files
committed
Improve hint message for ENOMEM failure from shmget().
It turns out that some platforms return ENOMEM for a request that violates SHMALL, whereas we were assuming that ENOSPC would always be used for that. Apparently the latter is a Linuxism while ENOMEM is the BSD tradition. Extend the ENOMEM hint to suggest that raising SHMALL might be needed. Per gripe from A.M. Backpatch to 9.0, but not further, because this doesn't seem important enough to warrant creating extra translation work in the stable branches. (If it were, we'd have figured this out years ago.)
1 parent 0d812f1 commit acac35a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/backend/port/sysv_shmem.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.57 2010/07/06 19:18:57 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.58 2010/08/25 20:10:55 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -135,7 +135,13 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
135135
}
136136

137137
/*
138-
* Else complain and abort
138+
* Else complain and abort.
139+
*
140+
* Note: at this point EINVAL should mean that either SHMMIN or SHMMAX
141+
* is violated. SHMALL violation might be reported as either ENOMEM
142+
* (BSDen) or ENOSPC (Linux); the Single Unix Spec fails to say which
143+
* it should be. SHMMNI violation is ENOSPC, per spec. Just plain
144+
* not-enough-RAM is ENOMEM.
139145
*/
140146
ereport(FATAL,
141147
(errmsg("could not create shared memory segment: %m"),
@@ -157,7 +163,9 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
157163
(unsigned long) size, NBuffers, MaxBackends) : 0,
158164
(errno == ENOMEM) ?
159165
errhint("This error usually means that PostgreSQL's request for a shared "
160-
"memory segment exceeded available memory or swap space. "
166+
"memory segment exceeded available memory or swap space, "
167+
"or exceeded your kernel's SHMALL parameter. You can either "
168+
"reduce the request size or reconfigure the kernel with larger SHMALL. "
161169
"To reduce the request size (currently %lu bytes), reduce "
162170
"PostgreSQL's shared_buffers parameter (currently %d) and/or "
163171
"its max_connections parameter (currently %d).\n"

0 commit comments

Comments
 (0)