From: Eric Marsden <eric.marsden@risk-engineering.org>
To: pgsql-bugs@lists.postgresql.org
Subject: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific)
Date: Fri, 21 Jun 2024 16:02:48 +0200
Message-ID: <2dcacb45-81c9-4c38-aa36-70e2dc8df487@risk-engineering.org> (raw)
Hello,
I have a strange bug which is either processor-specific (occurs on AMD
Ryzen 3 PRO 4350G processor, but not on Intel) or Linux kernel version
specific. It occurs with PostgreSQL v16.3 as packaged by Debian: 16.3
(Debian 16.3-1) on x86_64-pc-linux-gnu, compiled by gcc (Debian
13.2.0-24) 13.2.0, 64-bit, running on Linux 6.8.12-amd64 / Debian GLIBC
2.38-13.
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
The last line, which triggers the error, is using the
prepare-bind-execute protocol, with a single parameter sent in text
mode, with the oid corresponding to the "CREATE TYPE" (queried from the
pg_type table). This is with an obscure Emacs Lisp implementation of the
frontend/backend protocol. I have produced a standalone Emacs Lisp file
which reproduces the problem, available as a gist here
https://gist.github.com/emarsden/9bbaf02d62961cabaf5404f10da2c01c
To reproduce (requires Emacs to be installed), save as "cache-bug.el"
and run
PGURI="postgresql://pgeltestuser:password@localhost/pgeltestdb" emacs
--batch -Q -l cache-bug.el -f run
This produces a long backtrace of which the last line is (with FR locale)
PostgreSQL error: "ERREUR : cache lookup failed for type 34841"
I have not made the effort to reproduce this with the psycopg Python
library (the use of custom types is a little inconvenient).
This bug does not occur on the exact same version of PostgreSQL on
Debian (same sha256sum on the postmaster binary) running on an Intel
processor with an older kernel version. Nor does it occur on the problem
machine when running the current Docker image for PostgreSQL (neither
docker.io/library/postgres:16.3-bullseye nor the 16.3-alpine label).
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: eric.marsden@risk-engineering.org, pgsql-bugs@lists.postgresql.org
Subject: Re: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific)
In-Reply-To: <2dcacb45-81c9-4c38-aa36-70e2dc8df487@risk-engineering.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox