Re: deadlock between "WITH agg_tmp AS ({sel_stmt}), upd AS ({upd_stmt}) {ins_stmt}" and pure UPDATE statements

From: trafdev <trafdev(at)mail(dot)ru>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: deadlock between "WITH agg_tmp AS ({sel_stmt}), upd AS ({upd_stmt}) {ins_stmt}" and pure UPDATE statements
Date: 2016-07-04 01:53:13
Message-ID: cf602523-20d9-0efd-4ca3-947e8b15c212@mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've already switched to 'UPSERT', it didn't resolved deadlock issue by
itself... Added LOCK TABLE ... IN EXCLUSIVE MODE; to one session, hope
it will help.

> You did not mention what version of Postgres you are using, if it is
> 9.5+ you have the 'UPSERT' option available instead of using the WITH
> construct:
>
>
> https://www.postgresql.org/docs/9.5/static/sql-insert.html
>
> ON CONFLICT Clause
>
> https://www.depesz.com/2015/05/10/waiting-for-9-5-add-support-for-insert-on-conflict-do-nothingupdate/
>
>
> If not you might to take a look at:
>
> http://stackoverflow.com/questions/17267417/how-to-upsert-merge-insert-on-duplicate-update-in-postgres
>
>
> Bulk upsert with lock
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-07-04 04:06:31 Re: Unable to recovery due missing wal_file
Previous Message Patrick B 2016-07-04 01:50:37 Re: Unable to recovery due missing wal_file