Re: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific) / user error - Mailing list pgsql-bugs

From Eric Marsden
Subject Re: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific) / user error
Date
Msg-id 08e82e11-1018-4c01-b387-b2db5de6b455@risk-engineering.org
Whole thread Raw
In response to Re: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific)
Next
From: Amit Kapila
Date:
Subject: Re: Potential data loss due to race condition during logical replication slot creation