From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Andres Freund <andres(at)2ndquadrant(dot)com> |
Cc: | MauMau <maumau307(at)gmail(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [9.4 bug] The database server hangs with write-heavy workload on Windows |
Date: | 2014-10-13 15:57:21 |
Message-ID: | 543BF661.5070806@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 10/13/2014 06:26 PM, Andres Freund wrote:
> On 2014-10-13 17:56:10 +0300, Heikki Linnakangas wrote:
>> So the gist of the problem is that LWLockRelease doesn't wake up
>> LW_WAIT_UNTIL_FREE waiters, when releaseOK == false. It should, because a
>> LW_WAIT_UNTIL FREE waiter is now free to run if the variable has changed in
>> value, and it won't steal the lock from the other backend that's waiting to
>> get the lock in exclusive mode, anyway.
>
> I'm not a big fan of that change. Right now we don't iterate the waiters
> if releaseOK isn't set. Which is good for the normal lwlock code because
> it avoids pointer indirections (of stuff likely residing on another
> cpu).
I can't get excited about that. It's pretty rare for releaseOK to be
false, and when it's true, you iterate the waiters anyway.
> Wouldn't it be more sensible to reset releaseOK in *UpdateVar()? I
> might just miss something here.
That's not enough. There's no LWLockUpdateVar involved in the example I
gave. And LWLockUpdateVar() already wakes up all LW_WAIT_UNTIL_FREE
waiters, regardless of releaseOK.
Hmm, we could set releaseOK in LWLockWaitForVar(), though, when it
(re-)queues the backend. That would be less invasive, for sure
(attached). I like this better.
BTW, attached is a little test program I wrote to reproduce this more
easily. It exercises the LWLock* calls directly. To run, make and
install, and do "CREATE EXTENSION lwlocktest". Then launch three
backends concurrently that run "select lwlocktest(1)", "select
lwlocktest(2)" and "select lwlocktest(3)". It will deadlock within seconds.
- Heikki
Attachment | Content-Type | Size |
---|---|---|
releaseok-with-var-2.patch | text/x-diff | 1.1 KB |
lwlocktest.tar.gz | application/gzip | 1.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2014-10-13 16:17:54 | Re: Code bug or doc bug? |
Previous Message | Andres Freund | 2014-10-13 15:53:26 | Re: Hide 'Execution time' in EXPLAIN (COSTS OFF) |