Re: BUG #18484: "Cannot enlarge string buffer" during parallel execution of prepared statement/partitioning

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: michael.banck@netapp.com, pgsql-bugs@lists.postgresql.org
Date: 2024-05-30T01:26:20Z
Lists: pgsql-bugs

Attachments

On Wed, 29 May 2024 at 04:42, PG Bug reporting form
<noreply@postgresql.org> wrote:
> ERROR:  out of memory
> DETAIL:  Cannot enlarge string buffer containing 1073741812 bytes by 32 more
> bytes.

> I agree that the overall schema architecture should be rethought and much
> fewer partitions be used (and they are looking into this), but as the error
> does only happen with a parallel plan, I am reporting it here in case there
> is an easy fix for this, or at least maybe we can abort earlier with a
> better error message?

I think we should at least write a better error message.  "out of
memory" is misleading. I've attached a patch with some proposed better
wording.

The above will become:
ERROR:  string buffer exceeds maximum allowed length (1073741823)
DETAIL:  Cannot enlarge string buffer containing 1073741812 bytes by 32 more

I also see a few other places that report
ERRCODE_PROGRAM_LIMIT_EXCEEDED and display "out of memory". Namely:

pg_do_encoding_conversion
perform_default_encoding_conversion
pvsnprintf

We should probably consider fixing those too.

I understand this isn't to the level that you'd like to see this
fixed, but it at least should stop people from thinking that
installing more RAM might help.

David

Commits

  1. Improve enlargeStringInfo's ERROR message