Re: BUG #13935: Duplicate row in pg_constraint table which is not accessible via indexes

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: bear2k(at)mail(dot)ru
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13935: Duplicate row in pg_constraint table which is not accessible via indexes
Date: 2016-02-10 16:52:22
Message-ID: 20160210165222.GA347443@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

bear2k(at)mail(dot)ru wrote:

> First, select rows with segment scan:
>
> # select oid,ctid,xmin,xmax,conrelid,contype from pg_constraint where
> conrelid::int + 0 = 50621;
> oid | ctid | xmin | xmax | conrelid | contype
> --------+---------+---------+------+----------+---------
> 301952 | (6,136) | 4883898 | 0 | 50621 | p
> 300466 | (7,1) | 4786734 | 0 | 50621 | p
> (2 rows)

We've had reports of duplicate rows appearing in user tables, where only
one copy is visible through indexes, but most updates of pg_constraint
don't go through the normal executor, but rather direct catalog
manipulation of DDL implementation, so I'd be surprising if it's the
same thing. Also, the OIDs of the two rows are different, so really the
two physical rows are not update copies of the same logical row.

I wonder if you got into this state by adding primary keys concurrently
somehow. That should of course not be allowed, but of course there is
no UNIQUE constraint on conrelid itself, so the normal unique-ification
code in btree does not fire for this situation.

Perhaps we have a bug in some ALTER TABLE command. Can you tell us how
you created the PK in the affected table?

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2016-02-10 16:52:26 Re: BUG #13940: rollback prepared is not working
Previous Message David G. Johnston 2016-02-10 16:52:08 Re: BUG #13941: Different value "pg_constraint.consrc" for similar Check Constrait