Correct SQLSTATE for ENOMEM in file access

Started by Alexander Kuzmenkovabout 2 years ago4 messageshackers
Jump to latest
#1Alexander Kuzmenkov
akuzmenkov@timescale.com

Looking through the logs of some server that were experiencing out of
memory errors, I noticed that errcode_for_file_access() reports
ERRCODE_INTERNAL_ERROR for ENOMEM, while the correct SQLSTATE for this
should probably be ERRCODE_OUT_OF_MEMORY. Attached is a small patch to
fix this.

---
Alexander Kuzmenkov
Timescale

Attachments:

enomem-sqlstate-v1.patchtext/x-patch; charset=US-ASCII; name=enomem-sqlstate-v1.patchDownload+4-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alexander Kuzmenkov (#1)
Re: Correct SQLSTATE for ENOMEM in file access

Alexander Kuzmenkov <akuzmenkov@timescale.com> writes:

Looking through the logs of some server that were experiencing out of
memory errors, I noticed that errcode_for_file_access() reports
ERRCODE_INTERNAL_ERROR for ENOMEM, while the correct SQLSTATE for this
should probably be ERRCODE_OUT_OF_MEMORY. Attached is a small patch to
fix this.

Hmm, do you think this is actually reachable? AFAIK we should only be
calling errcode_for_file_access() after functions that are unlikely to
report ENOMEM.

regards, tom lane

#3Alexander Kuzmenkov
akuzmenkov@timescale.com
In reply to: Tom Lane (#2)
Re: Correct SQLSTATE for ENOMEM in file access

On Fri, Feb 2, 2024 at 8:12 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Hmm, do you think this is actually reachable? AFAIK we should only be
calling errcode_for_file_access() after functions that are unlikely to
report ENOMEM.

It's reachable, that's how I noticed. I'm seeing logs like "XX000:
could not load library \"/usr/lib/postgresql/15/lib/plpgsql.so\": out
of memory" from internal_load_library and so on. Not sure what is the
exact configuration required to reproduce this, probably at least the
overcommit should be disabled.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alexander Kuzmenkov (#3)
Re: Correct SQLSTATE for ENOMEM in file access

Alexander Kuzmenkov <akuzmenkov@timescale.com> writes:

On Fri, Feb 2, 2024 at 8:12 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Hmm, do you think this is actually reachable? AFAIK we should only be
calling errcode_for_file_access() after functions that are unlikely to
report ENOMEM.

It's reachable, that's how I noticed. I'm seeing logs like "XX000:
could not load library \"/usr/lib/postgresql/15/lib/plpgsql.so\": out
of memory" from internal_load_library and so on. Not sure what is the
exact configuration required to reproduce this, probably at least the
overcommit should be disabled.

OK, can't argue with experimental evidence ;-)

regards, tom lane