Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39715af

Browse files
committed
Fix broken mmap failure-detection code, and improve error message.
Per an observation by Thom Brown that my previous commit made anoverly large shmem allocation crash the server, on Linux.
1 parentb0fc0df commit39715af

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎src/backend/port/sysv_shmem.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,17 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
419419
*/
420420
AnonymousShmem=mmap(NULL,size,PROT_READ|PROT_WRITE,PG_MMAP_FLAGS,
421421
-1,0);
422-
if (AnonymousShmem==NULL)
422+
if (AnonymousShmem==MAP_FAILED)
423423
ereport(FATAL,
424-
(errmsg("could not map %lu bytes of anonymous shared memory: %m",
425-
(unsigned long)AnonymousShmemSize)));
424+
(errmsg("could not map anonymous shared memory: %m"),
425+
(errno==ENOMEM) ?
426+
errhint("This error usually means that PostgreSQL's request "
427+
"for a shared memory segment exceeded available memory "
428+
"or swap space. To reduce the request size (currently "
429+
"%lu bytes), reduce PostgreSQL's shared memory usage, "
430+
"perhaps by reducing shared_buffers or "
431+
"max_connections.",
432+
(unsigned long)AnonymousShmemSize) :0));
426433

427434
/* Now we can allocate a minimal SHM block. */
428435
allocsize=sizeof(PGShmemHeader);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp