pgsql: When building with LWLOCK_STATS, initialize the stats in LWLockW

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: When building with LWLOCK_STATS, initialize the stats in LWLockW
Date: 2012-02-07 08:15:05
Message-ID: E1RugCf-0001l6-F8@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

When building with LWLOCK_STATS, initialize the stats in LWLockWaitUntilFree.

If LWLockWaitUntilFree was called before the first LWLockAcquire call, you
would either crash because of access to uninitialized array or account the
acquisition incorrectly. LWLockConditionalAcquire doesn't have this problem
because it doesn't update the lwlock stats.

In practice, this never happens because there is no codepath where you would
call LWLockWaitUntilfree before LWLockAcquire after a new process is
launched. But that's just accidental, there's no guarantee that that's
always going to be true in the future.

Spotted by Jeff Janes.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/15ad6f1510f8979a39e4c39078c742b5fdb121ce

Modified Files
--------------
src/backend/storage/lmgr/lwlock.c | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2012-02-07 12:58:03 pgsql: createuser: Disable prompting by default
Previous Message Tom Lane 2012-02-06 20:30:32 pgsql: Fix postmaster to attempt restart after a hot-standby crash.