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

Appearance settings

Commit 93745f1

Browse filesBrowse files
committed
Fix memory leak on DSM slot exhaustion.
If we attempt to create a DSM segment when no slots are available, we should return the memory to the operating system. Previously we did that if the DSM_CREATE_NULL_IF_MAXSEGMENTS flag was passed in, but we didn't do it if an error was raised. Repair. Back-patch to 9.4, where DSM segments arrived. Author: Thomas Munro Reviewed-by: Robert Haas Reported-by: Julian Backes Discussion: https://postgr.es/m/CA%2BhUKGKAAoEw-R4om0d2YM4eqT1eGEi6%3DQot-3ceDR-SLiWVDw%40mail.gmail.com
1 parent 870ad6a commit 93745f1
Copy full SHA for 93745f1

File tree

Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Filter options
  • src/backend/storage/ipc
Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed

‎src/backend/storage/ipc/dsm.c

Copy file name to clipboardExpand all lines: src/backend/storage/ipc/dsm.c
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,16 @@ dsm_create(Size size, int flags)
479479
/* Verify that we can support an additional mapping. */
480480
if (nitems >= dsm_control->maxitems)
481481
{
482+
LWLockRelease(DynamicSharedMemoryControlLock);
483+
dsm_impl_op(DSM_OP_DESTROY, seg->handle, 0, &seg->impl_private,
484+
&seg->mapped_address, &seg->mapped_size, WARNING);
485+
if (seg->resowner != NULL)
486+
ResourceOwnerForgetDSM(seg->resowner, seg);
487+
dlist_delete(&seg->node);
488+
pfree(seg);
489+
482490
if ((flags & DSM_CREATE_NULL_IF_MAXSEGMENTS) != 0)
483-
{
484-
LWLockRelease(DynamicSharedMemoryControlLock);
485-
dsm_impl_op(DSM_OP_DESTROY, seg->handle, 0, &seg->impl_private,
486-
&seg->mapped_address, &seg->mapped_size, WARNING);
487-
if (seg->resowner != NULL)
488-
ResourceOwnerForgetDSM(seg->resowner, seg);
489-
dlist_delete(&seg->node);
490-
pfree(seg);
491491
return NULL;
492-
}
493492
ereport(ERROR,
494493
(errcode(ERRCODE_INSUFFICIENT_RESOURCES),
495494
errmsg("too many dynamic shared memory segments")));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.