Re: cache lookup failed when \d t concurrent with DML change column data type

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: cache lookup failed when \d t concurrent with DML change column data type
Date: 2024-10-25 03:05:45
Message-ID: 00e2c23e-f62c-4890-923b-aab8e0cc0d84@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/24/24 22:30, jian he wrote:
> hi. I think I found a bug.
> PostgreSQL 18devel_debug_build_45188c2ea2 on x86_64-linux, compiled by
> gcc-14.1.0, 64-bit
> commit at 45188c2ea2.
> Ubuntu 22.04.4 LTS
>
>
> setup:
> drop table t cascade;
> create table t(a int PRIMARY key);
>
> IN session1:
> step "change data type" {begin; alter table t alter column a set data
> type int4;}
> step "s1" {commit;}
>
> IN session2:
> step "psql_another_session" {\d t}
>
> permutation "change data type" "psql_another_session" "s1"

> ERROR: cache lookup failed for attribute 1 of relation 34418
Yes, it looks like a bug existing for a long time, at least since PG11
(I didn't trace further down).
It seems that the backend didn't apply invalidation messages before
touching system caches. Backtrace:

in get_attoptions (relid=16388, attnum=1) at lsyscache.c:982
in pg_get_indexdef_worker (indexrelid=16388, colno=0, excludeOps=0x0,
attrsOnly=false, keysOnly=false, showTblSpc=false, inherits=false,
prettyFlags=7, missing_ok=true) at ruleutils.c:1458
in pg_get_indexdef_ext (fcinfo=0x55a15acc1c18) at ruleutils.c:1202
in ExecInterpExpr (state=0x55a15acc2a10, econtext=0x55a15ac62930,
isnull=0x7fffd66a5bcf) at execExprInterp.c:770
in ExecInterpExprStillValid (state=0x55a15acc2a10,
econtext=0x55a15ac62930, isNull=0x7fffd66a5bcf) at execExprInterp.c:2035
in ExecEvalExprSwitchContext (state=0x55a15acc2a10,
econtext=0x55a15ac62930, isNull=0x7fffd66a5bcf) at
../../../src/include/executor/executor.h:367
in ExecProject (projInfo=0x55a15acc2a08) at
../../../src/include/executor/executor.h:401

--
regards, Andrei Lepikhov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message wenhui qiu 2024-10-25 03:38:57 Re: POC: make mxidoff 64 bits
Previous Message Michael Paquier 2024-10-25 01:58:13 Re: Missing installation of Kerberos.pm and AdjustUpgrade.pm