From: | "Jack Douglas" <jack(at)douglastechnology(dot)co(dot)uk> |
---|---|
To: | "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #13523: Unexplained deadlocks (possible race condition) |
Date: | 2015-07-28 18:09:25 |
Message-ID: | 01b001d0c960$894af9e0$9be0eda0$@douglastechnology.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
> I believe the issue with this is that a SQL function will do parsing (and
maybe planning too; don't feel like checking the code right now) for the
entire function body at once. This means that due to the INSERT command you
acquire RowExclusiveLock on the "test" table during function body parsing,
before the LOCK command actually executes. So the LOCK represents a lock
escalation attempt, and deadlocks are to be expected.
That makes perfect sense, many thanks for the explanation.
> This coding technique would be safe in plpgsql, but not in a SQL-language
function.
That's useful to know - I already worked around the issue with a retry-loop
(as I'm basically doing an upsert the 'bad' way with `lock table` - roll on
9.5!)
Kind regards
Jack
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2015-07-28 19:41:18 | Re: BUG #13518: CancelRequest lacks statement identifier |
Previous Message | Tom Lane | 2015-07-28 17:47:07 | Re: BUG #13523: Unexplained deadlocks (possible race condition) |