Re: how to avoid deadlock on masive update with multiples delete - Mailing list pgsql-performance

From Jeff Janes
Subject Re: how to avoid deadlock on masive update with multiples delete
Date
Msg-id CAMkU=1x_tM6ujEY39FUk=Lj2=NoT+-vJzoFMtwuKPN8Jd5PqrQ@mail.gmail.com
Whole thread Raw
In response to how to avoid deadlock on masive update with multiples delete  ("Anibal David Acosta" <aa@devshock.com>)
Responses Re: how to avoid deadlock on masive update with multiples delete
List pgsql-performance
On Thu, Oct 4, 2012 at 7:01 AM, Anibal David Acosta <aa@devshock.com> wrote:
> Hi,
>
> I have a table with about 10 millions of records, this table is update and
> inserted very often during the day (approx. 200 per second) , in the night
> the activity is a lot less, so in the first seconds of a day (00:00:01) a
> batch process update  some columns (used like counters) of this table
> setting his value to 0.
>
>
>
> Yesterday, the first time it occurs, I got a deadlock when other process try
> to delete multiple (about 10 or 20) rows of the same table.
...
>
> Any ideas how to prevent this situation?

The bulk update could take an Exclusive (not Access Exclusive) lock.
Or the delete could perhaps be arranged to delete the records in ctid
order (although that might still deadlock).  Or you could just repeat
the failed transaction.

Cheers,

Jeff


pgsql-performance by date:

Previous
From: "Anibal David Acosta"
Date:
Subject: how to avoid deadlock on masive update with multiples delete
Next
From: Colin Taylor
Date:
Subject: Re: A Tale of 2 algorithms