Re: foreign key on delete cascade order?

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: George Woodring <george(dot)woodring(at)iglass(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: foreign key on delete cascade order?
Date: 2022-03-12 03:03:09
Message-ID: CAHOFxGrZAZPeFKdDRLxhmtTvyyfVZtq8eJB_8CWFkpSUjm7Y=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> We are updating the entire status table every 5 minutes with
> BEGIN;
> UPDATE status SET () WHERE pollid = $1;
> COMMIT;
>
> The issue is arriving when some does a DELETE during the UPDATE of status
> DELETE FROM mach WHERE machid=$1;
>

Could you set lock_timeout, lock table explicitly for SHARE UPDATE
EXCLUSIVE (pretty sure that would be the proper level), then retry if it
fails because a delete is already going on?

Also, are you confident that before you call 'begin' to do the update, you
are not already in a transaction which might have some lock on row(s) in
mach, or one of the other tables involved?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-03-12 05:23:36 Re: Am I in the same transaction block in complex PLPGSQL?
Previous Message Dominique Devienne 2022-03-11 20:16:17 Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines