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.94.2) (envelope-from ) id 1sKh4S-00BdiO-23 for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2024 16:25:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sKh4Q-004ov8-4A for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2024 16:25:02 +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.94.2) (envelope-from ) id 1sKgwf-004dRt-1c for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2024 16:17:01 +0000 Received: from mail.risk-engineering.org ([2a01:4f8:c0c:a3f8::1]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sKgwd-002r0u-6z for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2024 16:17:00 +0000 DKIM-Signature: a=rsa-sha256; bh=d7AQOhuNKBV8+wjJ1DBQ5ze1ODJYpVKMsaqbtjFArFY=; c=relaxed/relaxed; d=risk-engineering.org; h=Subject:Subject:Sender:To:To:Cc:From:From:Date:Date:MIME-Version:MIME-Version:Content-Type:Content-Type:Content-Transfer-Encoding:Reply-To:In-Reply-To:In-Reply-To:Message-Id:Message-Id:References:References:Autocrypt:Openpgp; i=@risk-engineering.org; s=default; t=1718986639; v=1; x=1719418639; b=nIVUz2sZnEjdM11pcxa64rrzhzbjn8nALdPA+JC16obL2DgyrlCrjIHxw0xTltbGV58Yg/uF tGxPdgHbHlKbZXsh68GWw8bIxTsX9cR1fU2wysd0WXCCnH4cst15FVjHitZG0rkGsr0cs4SfiKv GvihVj/JXiXHsY6h0IBoj8KjJEvCiYmItzGwN4olDkG5BwZdWV8vzf8nEnevSH8+mTOJDQvIsaM HeSDD1p15oaDWjXfNk3exWsCnc/NRDqZUm1RR1n+gHpHoOTouaE5hvkxPvFh7jgVqZtiGZgAau2 QpsPNzc/wlWH1OJYH8sRrpiN5Nhb54hMuX0YJY3fVWQqw== Received: by mail.risk-engineering.org (envelope-sender ) with ESMTPS id 5646f33b; Fri, 21 Jun 2024 18:17:19 +0200 Content-Type: multipart/alternative; boundary="------------4EdpmPs9c6Wl68CboiAhjZwi" Message-ID: <08e82e11-1018-4c01-b387-b2db5de6b455@risk-engineering.org> Date: Fri, 21 Jun 2024 18:16:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific) / user error To: Tom Lane , pgsql-bugs@lists.postgresql.org References: <2dcacb45-81c9-4c38-aa36-70e2dc8df487@risk-engineering.org> <595887.1718984150@sss.pgh.pa.us> Content-Language: en-US From: Eric Marsden In-Reply-To: <595887.1718984150@sss.pgh.pa.us> 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. --------------4EdpmPs9c6Wl68CboiAhjZwi Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 21/06/2024 17:35, Tom Lane wrote: > Eric Marsden writes: >> I see a PostgreSQL error "cache lookup failed for type 34813" after the >> following sequence of network requests over a single network connection >> to PostgreSQL (which is otherwise idle): >> CREATE TYPE rating AS ENUM('ungood', 'good') >> CREATE TABLE act(name TEXT, value RATING) >> INSERT INTO act VALUES('thoughtcrime', 'ungood') -- OK >> INSERT INTO act VALUES('blackwhite', $1) -- with $1 = "good" / type oid for "rating" / text format Thanks to very useful discussions on #postgresql (IRC), I have found out that this is a user error rather than a PostgreSQL bug. My PostgreSQL network protocol library maintains an oid <-> type-name cache that is populated at connection startup time. Due to improper cleanup in the tests, a old value for the type oid was remaining when testing on my own computer (but not in Docker nor for clean test runs on other machines), so the PostgreSQL error message is perfectly valid. I have realized that I need to stop using this oid <-> type-name cache for types that are not PostgreSQL builtins, because there is no way of ensuring it's synchronized with the backend values. Thanks, and apologies for the spurious report, Eric --------------4EdpmPs9c6Wl68CboiAhjZwi Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 21/06/2024 17:35, Tom Lane wrote:
Eric Marsden <eric.marsden@risk-engineering.org> writes:
I see a PostgreSQL error "cache lookup failed for type 34813" after the 
following sequence of network requests over a single network connection 
to PostgreSQL (which is otherwise idle):
CREATE TYPE rating AS ENUM('ungood', 'good')
CREATE TABLE act(name TEXT, value RATING)
INSERT INTO act VALUES('thoughtcrime', 'ungood') -- OK
INSERT INTO act VALUES('blackwhite', $1) -- with $1 = "good" / type oid for "rating" / text format

    Thanks to very useful discussions on #postgresql (IRC), I have found
    out that this is a user error rather than a PostgreSQL bug. My
    PostgreSQL network protocol library maintains an oid <->
    type-name cache that is populated at connection startup time. Due to
    improper cleanup in the tests, a old value for the type oid was
    remaining when testing on my own computer (but not in Docker nor for
    clean test runs on other machines), so the PostgreSQL error message
    is perfectly valid. 

I have realized that I need to stop using this oid <-> type-name cache for types that are not PostgreSQL builtins, because there is no way of ensuring it's synchronized with the backend values.

Thanks, and apologies for the spurious report,
Eric

--------------4EdpmPs9c6Wl68CboiAhjZwi--