Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzvFl-004L5L-2d for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2026 12:00:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wzvFj-007PLu-2o for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2026 12:00:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzvFj-007PLl-1g for pgsql-hackers@lists.postgresql.org; Fri, 28 Aug 2026 12:00:11 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wzvFg-00000001iP3-3eP0 for pgsql-hackers@postgresql.org; Fri, 28 Aug 2026 12:00:11 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-499ae1c6471so6360905e9.3 for ; Fri, 28 Aug 2026 05:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787918403; x=1788523203; darn=postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=/gKNV7/hlGqJJWZ6EigYFXmX7USileyltA8TTMDNLzg=; b=mhftnYp23XBQWypP4LFo67wRsFj0Q21AJ4opUBOuzuqKiTX+5HPVkc54b0f9MNHkZe sYUttKpTU/0ZL3ALrVgJ1KAEWvrLtBa7N+Gs3PQxXGwSYyXOzGwnkeG4vS7Efc7ALaGc Wr6QPG2UfLruosh0mhqPy75O5vQY1IEQhYmt9DJyTaEGDRWBwyQDIMqG0N53xIiWjyKD vWXpBiMxOSsnFY9X1NGFD9Qna3E+jb0r7CzLENWMDSUtPSWsjST4+Oh2/wmKffV5Mdqt RrxIw/1IT4LZ5bqU2Vbb4jEmNNxbt1PkTl6QpWDAOfhk7rLj1jAjJneby/5y7op7BB+Y PDCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787918403; x=1788523203; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/gKNV7/hlGqJJWZ6EigYFXmX7USileyltA8TTMDNLzg=; b=J5ZjNLMKUXEg7LPnD3MMwI0Gh0QclIDbwUz1/1WqRt/x9/IynJMJUmtRPjvJ70UNea 0aTNpTdB5DEXF8FdLCR8cuHwD0x/qOyi2khu+5wu5iCp6CnCesQehm1iH10TNd5QlamI OvBao+K6IyhdtgoS8j9v5vOQJb81uI2TsOsraa9msi+96JLOCR78sbePCLJKlrRVEMSD XdGgroSjM2EFcN+eh3KssEe+hXk694zaGcsJHCdgy28Y6eEjXny46K2m6rdlLgf3DjXk bl2MBh67iT6Xq12LrUXDba8tw9jzHMkEAbwJND9KCGVi5cvBE1gXaB93s5BIpLkq8Bej K5PA== X-Forwarded-Encrypted: i=1; AHgh+RpcotekILigdkHWJqU1mpgPXBTKfoGBVQ1M9BuPTf34QV4wWxiCw+O6ryXSVoLFTmj7a1rVEAmrpoOfobi2@postgresql.org X-Gm-Message-State: AFuF++nnlVzlTOTtx8UinWp5fUs1K4L3FFDn9jObaHHubG2aHrD6xzY5 fnDixo90KTX+lRhZXBCs7qN/ssEA8M+LG9PEieiIfrtaih0XXGbp62mT X-Gm-Gg: AR+sD13gFHBfLWyA2moPXqqXiJ9oTc5O7RER4CZZrWUfTcUHNvpkmVh2tyxt4YpdtYd ULEz5TA0MxDI3vLbffqrh+dR96tbunkR7T5wbXRNJsDt50vHNzZJPG2ltCZtjIxihZOGNfCTVcM zOk5JqU9Ym0BqaskTXTdFjSqHWamF3wGVMHnD8BIVKh2qRlC5wybUUahQDYFfuVWUpVYbtmjRQZ 3/7dVMJgD9Ui4ZMbGSfq6Le0uAt4cA7C6+Ky6C0ZpiatNme3I892RRdJbIJSUZ8lM97Xayfzv4K tA4OiDvD6+TwLCULB3jpRAbg2VJ/rf86rPziE2/7ETEwzXue3cunuUKsLjnWiE9wTA0HChTF28T cTENGA6PMSoTqgAKf/YRDJ2M9+LY04bYQV7M8e1Ge82oNqncYCdlkVG+H56xmEAx08GOdOVi3mO xd7P2oFwhYE9kSMAqkLdAcnpKxAaPTrtZY3qAKA71WW4cuEbx7Zb3MYtfgG2p1pjy/X7k0RZBN+ w== X-Received: by 2002:a05:600d:8654:20b0:499:dae2:c613 with SMTP id 5b1f17b1804b1-49b91c509b5mr74995105e9.12.1787918402419; Fri, 28 Aug 2026 05:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.107.253]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49b91c9cf95sm45054515e9.1.2026.08.28.05.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Aug 2026 05:00:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------sKxs0v3ghZ5i4b1lZ3i0v02Z" Message-ID: <73eb724a-c1a3-456c-be12-0375d4556b67@gmail.com> Date: Fri, 28 Aug 2026 15:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Internal error codes triggered by regression tests and user queries, take 2 To: Andres Freund , Tom Lane Cc: Michael Paquier , pgsql-hackers , Justin Pryzby References: <94ac928b-8370-4db5-ada5-579a9ebc089d@gmail.com> <697477.1787754418@sss.pgh.pa.us> Content-Language: en-US From: Alexander Lakhin In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------sKxs0v3ghZ5i4b1lZ3i0v02Z Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello Andres and Tom, Thank you for your feedback! 26.08.2026 18:17, Andres Freund wrote: > On 2026-08-26 10:26:58 -0400, Tom Lane wrote: >> I'm not on board with these proposed changes to [try_]relation_open. >> They're basically band-aids rather than fixes of the root problems. >> That is, if someone passes OID 0 to relation_open, that IS an internal >> bug; labeling it otherwise is a lie and does nothing to fix the real >> problem at the caller level. I agree. The fact that the internal error is reached from a legal SQL-level function doesn't make all other ways to reach it expected/normal. This is one issue with this proposal. The other one is the unclear definition of internal/XX000 errors in principle. As far as I can see, it varies from "all the errors that have no specific code assigned" to "critical errors, similar to failed asserts" (and probably a substitute for asserts in production). And as Andres (and I too) find it useful to search for XX000 in production logs, it means they are interpreted per the second definition. In this case, it makes sense to define missing codes for cases which are not worth paying attention to in production, e.g. "#print_strict_params XXX". Moreover, if the second definition (XX000 error ~ failed assert) is going to be accepted, it seems sensible to have no such errors produced during regression tests (like no assertion failures). I remember previous moves in this direction: [1], [2], so I started from errors produced just by `make check`. I understand that such cases can be discussed and processed one-by-one (e.g., bug #19659, #19630, #19631, #19632), but given the number of "elog(ERROR)" in the tree and the number of known ways to reach them (dozens, I guess), maybe it would be more efficient to agree on the definition of internal errors and then categorize all the cases at hand (I thought of creating a wiki page for that). >> A lot of these other proposed changes have the same whiff of blaming >> the messenger rather than looking for the root cause. > +1. > > This is triply true for stuff like test_pglz_decompress() - this isn't > something that should be translated or that we care about having a proper > error code assigned. Yes, and this consideration (we don't care about error code) is closer to the definition 1, I guess. I proposed the change to align that error with the similar "compressed pglz data is corrupt", as it doesn't make the error less scary if we get back to the "search production logs for critical errors" use case (on the other hand, the error is produced by a test-only function...). > Most of these would make it *harder* to find unexpected scenarios, i.e. the > patch would make the situation strictly worse. It's useful to be able to > search production logs for internal errors. As-is the patch would break that. Yes, it would hardly land as-is, but I hope it can help determine ways to approach these errors in general. > Looking through them, the ones that look relatively clearly to be worth > turning into ereports seem to be: > > - pg_get_shmem_allocations_numa() - there's really no reason for this to be an > elog(), it's obviously expected to be reached on a bunch of platforms / configurations > - transformColumnDefinition() - that's clearly reachable with plain DDL, > without representing a bug in an upper layer. > > I'm a bit on the fence about the one get_range_io_data(). We could catch that > on a higher layer, but > a) that'd be duplicated code, > b) other errors, like not having send/receive are already handled in > get_range_io_data, with ereports() > c) for e.g. composites, we handle the same problem centrally, rather than have > checks in record_in() etc (the check is in lookup_rowtype_tupdesc_internal). I would elaborate on these when the consensus on the definition is reached. [1] https://www.postgresql.org/message-id/flat/ba76c6bc-f03f-4285-bf16-47759cfcab9e%40eisentraut.org [2] https://www.postgresql.org/message-id/Zic_GNgos5sMxKoa%40paquier.xyz Best regards, Alexander --------------sKxs0v3ghZ5i4b1lZ3i0v02Z Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
Hello Andres and Tom,

Thank you for your feedback!

26.08.2026 18:17, Andres Freund wrote:
On 2026-08-26 10:26:58 -0400, Tom Lane wrote:
I'm not on board with these proposed changes to [try_]relation_open.
They're basically band-aids rather than fixes of the root problems.
That is, if someone passes OID 0 to relation_open, that IS an internal
bug; labeling it otherwise is a lie and does nothing to fix the real
problem at the caller level.

I agree. The fact that the internal error is reached from a legal SQL-level
function doesn't make all other ways to reach it expected/normal. This is
one issue with this proposal.

The other one is the unclear definition of internal/XX000 errors in
principle. As far as I can see, it varies from "all the errors that have
no specific code assigned" to "critical errors, similar to failed asserts"
(and probably a substitute for asserts in production). And as Andres (and
I too) find it useful to search for XX000 in production logs, it means
they are interpreted per the second definition. In this case, it makes
sense to define missing codes for cases which are not worth paying
attention to in production, e.g. "#print_strict_params XXX". Moreover, if
the second definition (XX000 error ~ failed assert) is going to be
accepted, it seems sensible to have no such errors produced during
regression tests (like no assertion failures).

I remember previous moves in this direction: [1], [2], so I started from
errors produced just by `make check`. I understand that such cases can be
discussed and processed one-by-one (e.g., bug #19659, #19630, #19631,
#19632), but given the number of "elog(ERROR)" in the tree and the number
of known ways to reach them (dozens, I guess), maybe it would be more
efficient to agree on the definition of internal errors and then
categorize all the cases at hand (I thought of creating a wiki page for
that).

A lot of these other proposed changes have the same whiff of blaming
the messenger rather than looking for the root cause.
+1.

This is triply true for stuff like test_pglz_decompress() - this isn't
something that should be translated or that we care about having a proper
error code assigned.

Yes, and this consideration (we don't care about error code) is closer to
the definition 1, I guess. I proposed the change to align that error with
the similar "compressed pglz data is corrupt", as it doesn't make the
error less scary if we get back to the "search production logs for
critical errors" use case (on the other hand, the error is produced by a
test-only function...).

Most of these would make it *harder* to find unexpected scenarios, i.e. the
patch would make the situation strictly worse. It's useful to be able to
search production logs for internal errors. As-is the patch would break that.

Yes, it would hardly land as-is, but I hope it can help determine ways to
approach these errors in general.

Looking through them, the ones that look relatively clearly to be worth
turning into ereports seem to be:

- pg_get_shmem_allocations_numa() - there's really no reason for this to be an
  elog(), it's obviously expected to be reached on a bunch of platforms / configurations
- transformColumnDefinition() - that's clearly reachable with plain DDL,
  without representing a bug in an upper layer.

I'm a bit on the fence about the one get_range_io_data(). We could catch that
on a higher layer, but
a) that'd be duplicated code,
b) other errors, like not having send/receive are already handled in
   get_range_io_data, with ereports()
c) for e.g. composites, we handle the same problem centrally, rather than have
   checks in record_in() etc (the check is in lookup_rowtype_tupdesc_internal).

I would elaborate on these when the consensus on the definition is reached.

[1] https://www.postgresql.org/message-id/flat/ba76c6bc-f03f-4285-bf16-47759cfcab9e%40eisentraut.org
[2] https://www.postgresql.org/message-id/Zic_GNgos5sMxKoa%40paquier.xyz

Best regards,
Alexander
--------------sKxs0v3ghZ5i4b1lZ3i0v02Z--