1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Be more specific about OOM in XLogReaderAllocate

A couple of spots can benefit from an added errdetail(), which matches
what we were already doing in other places; and those that cannot
withstand errdetail() can get a more descriptive primary message.

Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Discussion: https://postgr.es/m/CALj2ACV+cX1eM03GfcA=ZMLXh5fSn1X1auJLz3yuS1duPSb9QA@mail.gmail.com
This commit is contained in:
Alvaro Herrera
2021-11-22 13:43:43 -03:00
parent 042412879e
commit 2fed48f48f
5 changed files with 9 additions and 7 deletions

View File

@ -1265,7 +1265,7 @@ XLogInsertRecord(XLogRecData *rdata,
if (!debug_reader) if (!debug_reader)
{ {
appendStringInfoString(&buf, "error decoding record: out of memory"); appendStringInfoString(&buf, "error decoding record: out of memory while allocating a WAL reading processor");
} }
else if (!DecodeXLogRecord(debug_reader, (XLogRecord *) recordBuf.data, else if (!DecodeXLogRecord(debug_reader, (XLogRecord *) recordBuf.data,
&errormsg)) &errormsg))

View File

@ -202,7 +202,8 @@ StartupDecodingContext(List *output_plugin_options,
if (!ctx->reader) if (!ctx->reader)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory"),
errdetail("Failed while allocating a WAL reading processor.")));
ctx->reorder = ReorderBufferAllocate(); ctx->reorder = ReorderBufferAllocate();
ctx->snapshot_builder = ctx->snapshot_builder =

View File

@ -681,7 +681,8 @@ StartReplication(StartReplicationCmd *cmd)
if (!xlogreader) if (!xlogreader)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory"),
errdetail("Failed while allocating a WAL reading processor.")));
/* /*
* We assume here that we're logging enough information in the WAL for * We assume here that we're logging enough information in the WAL for

View File

@ -74,7 +74,7 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex,
XL_ROUTINE(.page_read = &SimpleXLogPageRead), XL_ROUTINE(.page_read = &SimpleXLogPageRead),
&private); &private);
if (xlogreader == NULL) if (xlogreader == NULL)
pg_fatal("out of memory"); pg_fatal("out of memory while allocating a WAL reading processor");
XLogBeginRead(xlogreader, startpoint); XLogBeginRead(xlogreader, startpoint);
do do
@ -132,7 +132,7 @@ readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex,
XL_ROUTINE(.page_read = &SimpleXLogPageRead), XL_ROUTINE(.page_read = &SimpleXLogPageRead),
&private); &private);
if (xlogreader == NULL) if (xlogreader == NULL)
pg_fatal("out of memory"); pg_fatal("out of memory while allocating a WAL reading processor");
XLogBeginRead(xlogreader, ptr); XLogBeginRead(xlogreader, ptr);
record = XLogReadRecord(xlogreader, &errormsg); record = XLogReadRecord(xlogreader, &errormsg);
@ -192,7 +192,7 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex,
XL_ROUTINE(.page_read = &SimpleXLogPageRead), XL_ROUTINE(.page_read = &SimpleXLogPageRead),
&private); &private);
if (xlogreader == NULL) if (xlogreader == NULL)
pg_fatal("out of memory"); pg_fatal("out of memory while allocating a WAL reading processor");
searchptr = forkptr; searchptr = forkptr;
for (;;) for (;;)

View File

@ -1061,7 +1061,7 @@ main(int argc, char **argv)
.segment_close = WALDumpCloseSegment), .segment_close = WALDumpCloseSegment),
&private); &private);
if (!xlogreader_state) if (!xlogreader_state)
fatal_error("out of memory"); fatal_error("out of memory while allocating a WAL reading processor");
/* first find a valid recptr to start from */ /* first find a valid recptr to start from */
first_record = XLogFindNextRecord(xlogreader_state, private.startptr); first_record = XLogFindNextRecord(xlogreader_state, private.startptr);