Attached is a patch for xlogreader.c for a more informative error message
for allocate_recordbuf() failure.

The patch details are:

   - Project name.: None

   - Uniquely identifiable file name, so we can tell difference between
   your v1 and v24.:  src/backend/access/transam/xlogreader.c

   - What the patch does in a short paragraph.:

The patch enhances the error message when memory cannot be allocated to
extend the readRecordBuf.  The previous error message was implying an
invalid (too long) record length and also did not specify how much memory
we were trying to allocate when the memory allocation failure happened.

We have observed failed allocations in production systems where the
reclength was only 344 bytes, but the extended allocation of 5 *
Max(BLKSIZE, XLOG_BLCKSZ) failed due to out of memory.

   - Whether the patch is for discussion or for application (see WIP notes
   below): for application.

   - Which branch the patch is against (ordinarily this will be *master*).
   For more on branches in PostgreSQL, see Using Back Branches

   - Whether it compiles and tests successfully, so we know nothing obvious
   is broken.:  Yes.  We ran make check and all 166 tests passed.

   - Whether it contains any platform-specific items and if so, has it been
   tested on other platforms.:  Nothing platform specific.

   - Confirm that the patch includes regression tests
   <https://wiki.postgresql.org/wiki/Regression_test_authoring> to check
   the new feature actually works as described.:  None.

   - Include documentation on how to use the new feature, including
   examples. See the documentation documentation
   <http://www.postgresql.org/docs/current/static/docguide.html> for more
   information.:  None needed.

   - Describe the effect your patch has on performance, if any.:  None.

   - Try to include a few lines about why you chose to do things particular
   ways, rather than let your reviewer guess what was happening. This can be
   done as code comments, but it might also be an additional reviewers' guide,
   or additions to a README file in one of the code directories.:

Besides making the error message more informative, we had to modify
allocate_recordbuf() to return the actual number of bytes that were being

   - If your patch addresses a Todo
<https://wiki.postgresql.org/wiki/Todo> item,
   please give the name of the Todo item in your email. This is so that the
   reviewers will know that the item needs to be marked as done if your patch
   is applied.:  None.

Thank you.

Shoaib Lari

Attachment: fix_error_message_for_allocate_recordbuf_failure.patch
Description: Binary data

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to