Report memory context stats upon out-of-memory in repalloc[_huge].
authorTom Lane <[email protected]>
Sun, 13 Mar 2016 05:21:07 +0000 (00:21 -0500)
committerTom Lane <[email protected]>
Sun, 13 Mar 2016 05:21:07 +0000 (00:21 -0500)
This longstanding functionality evidently got lost in commit
3d6d1b585524aab6.  Noted while studying an OOM report from Jaime
Casanova.  Backpatch to 9.5 where the bug was introduced.

src/backend/utils/mmgr/mcxt.c

index 34f4e7202f25854d4493a24b33131f0a45f5c7c8..01773ffb01b52beddbd80615628867a7862d95a4 100644 (file)
@@ -969,10 +969,13 @@ repalloc(void *pointer, Size size)
 
    ret = (*context->methods->realloc) (context, pointer, size);
    if (ret == NULL)
+   {
+       MemoryContextStats(TopMemoryContext);
        ereport(ERROR,
                (errcode(ERRCODE_OUT_OF_MEMORY),
                 errmsg("out of memory"),
                 errdetail("Failed on request of size %zu.", size)));
+   }
 
    VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
 
@@ -1049,10 +1052,13 @@ repalloc_huge(void *pointer, Size size)
 
    ret = (*context->methods->realloc) (context, pointer, size);
    if (ret == NULL)
+   {
+       MemoryContextStats(TopMemoryContext);
        ereport(ERROR,
                (errcode(ERRCODE_OUT_OF_MEMORY),
                 errmsg("out of memory"),
                 errdetail("Failed on request of size %zu.", size)));
+   }
 
    VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);