Re: Row locking during UPDATE

From: Sam Barnett-Cormack <s(dot)barnett-cormack(at)lancaster(dot)ac(dot)uk>
To: "David F(dot) Skoll" <dfs(at)roaringpenguin(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Row locking during UPDATE
Date: 2003-09-04 15:32:26
Message-ID: Pine.LNX.4.50.0309041630500.28585-100000@short.lancs.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, 4 Sep 2003, David F. Skoll wrote:

> > Zapping clients that are in the middle of database operations is bad
> > design IMHO.
>
> It's required. The clients are e-mail filters and they must reply
> quickly, before the end of the SMTP transaction. If they take too long,
> they must be killed so the SMTP transaction can be tempfailed. If they
> are not killed, the SMTP sessions pile up and eventually kill the machine.

It might be worth racking your brains to think of other ways. Query
timeouts?

> > That's correct, a backend will generally not notice client disconnect
> > until it next waits for a client command. It's not totally clear why
> > you've got so many processes waiting to update the same row, though.
>
> It's on a high-volume mail server that receives around 500K
> messages/day. About 180,000 of those are viruses, so we often have
> multiple processes trying to update the virus statistics row.
>
> > Which process does have the row lock, and why isn't it completing its
> > transaction?
>
> I don't know the details of PostgreSQL's implementation, but it seems
> that when lots of processes are waiting to update the same row, it
> gets incredibly slow.

All trying to access the same row seems a bad idea generally. Instead,
why not make it store a new record for each instance, and have a cronjob
each day update the statistics from that. It will be more efficient,
overall. It can be done hourly, even.

--

Sam Barnett-Cormack
Software Developer | Student of Physics & Maths
UK Mirror Service (http://www.mirror.ac.uk) | Lancaster University

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Diko Sastroprawiro 2003-09-04 15:33:15 unsubscribe
Previous Message Tom Lane 2003-09-04 15:25:08 Re: Row locking during UPDATE