Re: lwlocks and starvation

From: Neil Conway <neilc(at)samurai(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lwlocks and starvation
Date: 2004-11-25 11:28:50
Message-ID: 41A5C1F2.1050803@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs wrote:
> I'd been thinking about lock release order also, thinking that this
> could be related to the CS storms observed earlier and the apparent
> lock-step behaviour commented upon previously.

As much as I would love to believe this (because it would mean we could
probably solve the problem pretty easily), I don't think lock release
order is the (primary) culprit behind the CS storm issue. As I
understand it, the heavily contended lock in those situations is the
BufMgrLock, and that is _always_ acquired in exclusive mode.

> ISTM that waking
> shared waiters in xid order would bring the most benefit and minimise
> any data issues. Readers waiting behind an exclusive waiter, where the
> reader has a lower xid might reasonably be woken without a problem since
> they will never see the changes made by the exclusive waiter anyway.

I'm not sure I understand. What "data issues" are you referring to?
LWLocks are used to protect non-transactional resources (such as shared
memory data structures), so the relative xids of two waiter processes
doesn't affect whether they can see each other's modifications (i.e.
because they always can).

In any case, the idea of considering information such as the xid when
deciding which waiters to release is interesting. It's not immediately
apparent to me quite *how* to make use of that info, but it's definitely
something to consider...

-Neil

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2004-11-25 12:07:54 Re: lwlocks and starvation
Previous Message Richard Huxton 2004-11-25 11:24:36 Re: [HACKERS] Help!