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 1sKf2J-00BVUD-BN for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2024 14:14:43 +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 1sKf2H-001kMB-NY for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2024 14:14:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKeqv-001Xsv-2P for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2024 14:02:57 +0000 Received: from mail.risk-engineering.org ([2a01:4f8:c0c:a3f8::1]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sKeqs-002QIA-4e for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2024 14:02:55 +0000 DKIM-Signature: a=rsa-sha256; bh=qGSZ7vKqhEndnXM1iT+jCOj0R6HUBzVy7E/APNcKuMI=; 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:Content-Transfer-Encoding:Reply-To:In-Reply-To:Message-Id:Message-Id:References:Autocrypt:Openpgp; i=@risk-engineering.org; s=default; t=1718978594; v=1; x=1719410594; b=kTp5aNZOllPb5l4I5kTb8Xo4SKysElJu5RTMcm+4I5ipcNRooJC2dNedaGDIzvdaZuhwhBrh iOSB6t6SuTZ56tdROZyWiEQDo8TpIRGkU8+UumjCmikY3RhMVCSgc65uvXHZcXZhwSh/PYjehcT UDeArHKgbR+JVBn3XWvQxOvLS51hMRG19isofrMM7Llw5XI+4NasCoVjhFyRyA5Zxw5m5VK9h8S Zh3Tk7KnqEzzehXJiGdpS40LOFJBjJpqcGB9VjGnXIjFadkigkgbOJOs2pyNiCsjy5xRL2oZUlC FCMa3VPJszo3vrXkO4dCSljUEXMVYes2wo7gYXt4g+VWA== Received: by mail.risk-engineering.org (envelope-sender ) with ESMTPS id c2f30651; Fri, 21 Jun 2024 16:03:14 +0200 Message-ID: <2dcacb45-81c9-4c38-aa36-70e2dc8df487@risk-engineering.org> Date: Fri, 21 Jun 2024 16:02:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: pgsql-bugs@lists.postgresql.org From: Eric Marsden Subject: Cache lookup failed for type 34813 (CREATE TYPE AS ENUM + P/B/E insert, processor-specific) Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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).