pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: kurt@roeckx.be
Subject: BUG #15868: Creating foreign key fails to find data key that exists
Date: Sat, 22 Jun 2019 17:49:15 +0000
Message-ID: <15868-bb20413c3ae554fb@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15868
Logged by:          Kurt Roeckx
Email address:      kurt@roeckx.be
PostgreSQL version: 11.3
Operating system:   Debian
Description:        

Hi,

I've dumped and and started a restore of a large database (the restore is
sitll in progress.) The data was in a 10.8 version, and it's being imported
in an 11.3 version.

The following 2 queries returned an error:
ALTER TABLE ONLY public.certificates
    ADD CONSTRAINT certificates_raw_certificate_id_fkey FOREIGN KEY
(raw_certificate_id) REFERENCES public.raw_certificates(id);
ERROR:  insert or update on table "certificates" violates foreign key
constraint "certificates_raw_certificate_id_fkey"
DETAIL:  Key (raw_certificate_id)=(162071571) is not present in table
"raw_certificates".

ALTER TABLE ONLY public.ct_entry
    ADD CONSTRAINT ct_entry_raw_certificate_id_fkey FOREIGN KEY
(raw_certificate_id) REFERENCES public.raw_certificates(id);
ERROR:  insert or update on table "ct_entry" violates
foreign key constraint "ct_entry_raw_certificate_id_fkey"
DETAIL:  Key (raw_certificate_id)=(521867241) is not present in table
"raw_certificates".

Both ids (162071571 and  521867241) exist in the raw_certificates table.

The id field looks like:
       Column       |  Type   | Collation | Nullable |                  
Default
--------------------+---------+-----------+----------+---------------------------------------------
 id                 | bigint  |           | not null |
nextval('raw_certificate_id_seq'::regclass)

It's a rather large table. The data itself is about 2.2 TB, it contains
about 2G entries, the index on the id colum is 32 GB. Running the queries
above takes a very long time.

Kurt



Message-ID: <15868-bb20413c3ae554fb@postgresql.org>
Permalink:  ../15868-bb20413c3ae554fb@postgresql.org/
Also on:    postgresql.org/message-id/15868-bb20413c3ae554fb@postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, kurt@roeckx.be
  Subject: Re: BUG #15868: Creating foreign key fails to find data key that exists
  In-Reply-To: <15868-bb20413c3ae554fb@postgresql.org>
  References: <15868-bb20413c3ae554fb@postgresql.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