Re: Rows violating Foreign key constraint exists

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nandakumar M <m(dot)nanda92(at)gmail(dot)com>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Rows violating Foreign key constraint exists
Date: 2019-11-29 15:23:25
Message-ID: 13475.1575041005@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Nandakumar M <m(dot)nanda92(at)gmail(dot)com> writes:
>> It could be that somebody disabled the triggers, but that would have to
>> be a superuser. And I hope that people randomly disabling system triggers
>> on tables don't have superuser access to your database.

> It is unlikely that this happened. So I am assuming corruption.
> But I am able to query both the referred and referring table
> successfully without any 'missing chunk' or similar errors that
> usually indicate corruption.
> Is it possible that corruption might cause data loss like this without
> any errors?

The most likely "corruption" explanation is something wrong with the
indexes on the referenced and/or referencing column, causing rows to
not be found when referential actions should have found them. Random
querying of the tables wouldn't necessarily expose that --- you'd need
to be sure that your queries use the questionable indexes, and maybe
even search for some of the specific rows that seem mis-indexed.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2019-11-29 16:38:40 Counting booleans in GROUP BY sections
Previous Message Nandakumar M 2019-11-29 09:02:35 Re: Rows violating Foreign key constraint exists