Re: BUG #19968: ALTER COLUMN TYPE fails with internal errors if a dependent object is dropped concurrently

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: aman(at)stack-auth(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19968: ALTER COLUMN TYPE fails with internal errors if a dependent object is dropped concurrently
Date: 2026-12-03 17:57:38
Message-ID: CALdSSPhQ+C8vFDLhxT-0-J6hn7iFpPyxj4cxzkspHymv+8vhPA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 2 Dec 2026 at 17:30, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
>
> The following bug has been logged on the website:
>

Hi

> Setup: the official postgres:19.0 Docker image, started with
>
> docker run -d --name pg19 --cap-add=SYS_PTRACE \
> -e POSTGRES_HOST_AUTH_METHOD=trust \
> -e POSTGRES_INITDB_ARGS="--locale=C.UTF-8 --encoding=UTF8" -e TZ=UTC \
> postgres:19.0 postgres -c log_error_verbosity=verbose
>
> and gdb installed in it (apt-get update && apt-get install -y gdb).
>
> Steps, in a new, empty database:
>
> CREATE TABLE t (id int, v int);
> CREATE VIEW tv AS SELECT v FROM t;
>
> Session 1 (psql -X):
> \set VERBOSITY verbose
> SELECT pg_backend_pid();
>
> gdb, as the postgres user in the container:
> gdb -p <pid from session 1>
> (gdb) break getObjectDescription
> (gdb) continue
>
> Session 1:
> ALTER TABLE t ALTER COLUMN v TYPE bigint;
> -- stops at the breakpoint
>
> Session 2 (psql -X):
> DROP VIEW tv;
>
> gdb:
> (gdb) continue
>
> Session 1 then prints:
>
> ERROR: XX000: could not find tuple for rule 16408
> LOCATION: getObjectDescription, objectaddress.c:3433
>
> Same steps with a function or a publication instead of the view:
>
> CREATE FUNCTION f() RETURNS int BEGIN ATOMIC SELECT v FROM t; END;
> (dropped with DROP FUNCTION f();)
>
> ERROR: 0A000: cannot alter type of a column used by a function or procedure
> DETAIL: (null) depends on column "v".
> LOCATION: RememberAllDependentForRebuilding, tablecmds.c:16243
>
> CREATE PUBLICATION p FOR TABLE t WHERE (v > 0);
> (dropped with DROP PUBLICATION p;)
>
> ERROR: XX000: cache lookup failed for publication table 16419
> LOCATION: getObjectDescription, objectaddress.c:4067
>
> On master I also got this with a sequence OWNED BY t.v (breaking in
> get_rel_relkind() instead): "ERROR: XX000: cache lookup failed for
> relation NNNNN".
>
> Expected: no internal error. Once the object is gone it doesn't depend
> on the column anymore, so I'd expect the ALTER to just go through, like
> it does if you drop the object before running the ALTER.

Agree, its a real bug.

>
> I believe I have a patch with an isolation test, I'll post it as a reply.

Please share.

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Rachitskiy 2026-12-03 18:13:05 Re: BUG #19956: json #>, #>> and json_extract_path resolve a negative array index against an earlier sibling array
Previous Message Nathan Bossart 2026-12-03 17:32:45 Re: JSON_SERIALIZE for JSONB returns parts of the internal JSONB representation