Be more specific about OOM in XLogReaderAllocate
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 22 Nov 2021 16:43:43 +0000 (13:43 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 22 Nov 2021 16:43:43 +0000 (13:43 -0300)
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

src/backend/access/transam/xlog.c
src/backend/replication/logical/logical.c
src/backend/replication/walsender.c
src/bin/pg_rewind/parsexlog.c
src/bin/pg_waldump/pg_waldump.c

index 33bb0229aa74c54e44750a7b00ddbafac539cf90..221e4cb34f88626a8be93730978e2ada706363d4 100644 (file)
@@ -1265,7 +1265,7 @@ XLogInsertRecord(XLogRecData *rdata,
 
        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,
                                   &errormsg))
index b7d95215764d77a19884bf36004d80c01c568da3..10cbdea124cde460fa177aa54252fb9449f5edd6 100644 (file)
@@ -202,7 +202,8 @@ StartupDecodingContext(List *output_plugin_options,
    if (!ctx->reader)
        ereport(ERROR,
                (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->snapshot_builder =
index 7950afb173c7e119efa3c1b85e9ddd7fb6b431a0..84915ed95bdd983a509c1eaf798d80b2349cbeca 100644 (file)
@@ -681,7 +681,8 @@ StartReplication(StartReplicationCmd *cmd)
    if (!xlogreader)
        ereport(ERROR,
                (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
index 59ebac7d6aa8832287b6fbf184cc2b0123475b17..436df54120179be6dcfbec84fe0a89682a6a1989 100644 (file)
@@ -74,7 +74,7 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex,
                                    XL_ROUTINE(.page_read = &SimpleXLogPageRead),
                                    &private);
    if (xlogreader == NULL)
-       pg_fatal("out of memory");
+       pg_fatal("out of memory while allocating a WAL reading processor");
 
    XLogBeginRead(xlogreader, startpoint);
    do
@@ -132,7 +132,7 @@ readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex,
                                    XL_ROUTINE(.page_read = &SimpleXLogPageRead),
                                    &private);
    if (xlogreader == NULL)
-       pg_fatal("out of memory");
+       pg_fatal("out of memory while allocating a WAL reading processor");
 
    XLogBeginRead(xlogreader, ptr);
    record = XLogReadRecord(xlogreader, &errormsg);
@@ -192,7 +192,7 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex,
                                    XL_ROUTINE(.page_read = &SimpleXLogPageRead),
                                    &private);
    if (xlogreader == NULL)
-       pg_fatal("out of memory");
+       pg_fatal("out of memory while allocating a WAL reading processor");
 
    searchptr = forkptr;
    for (;;)
index 1e3894b9c4550c958313a420e86007a2a3b474ce..4690e0f51561149095dc344842b18b4c62ee09ff 100644 (file)
@@ -1061,7 +1061,7 @@ main(int argc, char **argv)
                                      .segment_close = WALDumpCloseSegment),
                           &private);
    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_record = XLogFindNextRecord(xlogreader_state, private.startptr);