mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Report memory context stats upon out-of-memory in repalloc[_huge].
This longstanding functionality evidently got lost in commit
3d6d1b5855
. Noted while studying an OOM report from Jaime
Casanova. Backpatch to 9.5 where the bug was introduced.
This commit is contained in:
@ -1051,10 +1051,13 @@ repalloc(void *pointer, Size size)
|
|||||||
|
|
||||||
ret = (*context->methods->realloc) (context, pointer, size);
|
ret = (*context->methods->realloc) (context, pointer, size);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
|
{
|
||||||
|
MemoryContextStats(TopMemoryContext);
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||||
errmsg("out of memory"),
|
errmsg("out of memory"),
|
||||||
errdetail("Failed on request of size %zu.", size)));
|
errdetail("Failed on request of size %zu.", size)));
|
||||||
|
}
|
||||||
|
|
||||||
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
|
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
|
||||||
|
|
||||||
@ -1131,10 +1134,13 @@ repalloc_huge(void *pointer, Size size)
|
|||||||
|
|
||||||
ret = (*context->methods->realloc) (context, pointer, size);
|
ret = (*context->methods->realloc) (context, pointer, size);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
|
{
|
||||||
|
MemoryContextStats(TopMemoryContext);
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||||
errmsg("out of memory"),
|
errmsg("out of memory"),
|
||||||
errdetail("Failed on request of size %zu.", size)));
|
errdetail("Failed on request of size %zu.", size)));
|
||||||
|
}
|
||||||
|
|
||||||
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
|
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user