From: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: How does this FK constraint error happen? |
Date: | 2024-07-15 14:35:18 |
Message-ID: | 20240715143518.3v5xdfuj27ryzuzh@hjp.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2024-07-15 10:04:39 -0400, Ron Johnson wrote:
> The job does DELETE FROM rel_group_user; (no WHERE clause!!) then does DELETE
> FROM public.access_user; (also no WHERE clause), but the public.access_user
> statement fails on FK constraint error on rel_group_user (which was just
> recently emptied).
>
> Each statement is in a different transaction, since they are executed via
> separate psql statements. Thus, no apparent MVCC visibility weirdness.
>
> My first thought, of course, was that there are two rel_group_user tables.
> Alas, no, there's just one. See below for grep statement.
>
> Excerpts from the cron job log file:
> [snip]
> 2024-07-15 02:40:04 Deleting from FISPTAPPGS401DA/TAPd.rel_group_user
> DELETE FROM rel_group_user;
> DELETE 42747
> [snip]
> 2024-07-15 02:41:15 Deleting from FISPTAPPGS401DA/TAPd.public.access_user
> DELETE FROM public.access_user;
> ERROR: update or delete on table "access_user" violates foreign key constraint
> "fk_rel_group_user_1" on table "rel_group_user"
> DETAIL: Key (user_id)=(1210) is still referenced from table "rel_group_user".
> ERROR: deleting FISPTAPPGS401DA/TAPd.public.access_user
> [snip]
Is it possible that some other process created an entry in
rel_group_user between these two queries?
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
From | Date | Subject | |
---|---|---|---|
Next Message | Shenavai, Manuel | 2024-07-15 14:42:41 | Monitoring DB size |
Previous Message | Peter J. Holzer | 2024-07-15 14:27:44 | Re: Dropping column from big table |