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