Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A75786346C5 for ; Sun, 27 Dec 2009 15:14:24 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 54963-06-4 for ; Sun, 27 Dec 2009 19:14:08 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.anarazel.de (mail.anarazel.de [217.115.131.40]) by mail.postgresql.org (Postfix) with ESMTP id 0D991633C9A for ; Sun, 27 Dec 2009 15:12:42 -0400 (AST) Received: from alap2.localnet (unknown [81.163.101.249]) by mail.anarazel.de (Postfix) with ESMTPSA id 8A97E448003; Sun, 27 Dec 2009 20:12:40 +0100 (CET) From: Andres Freund To: Simon Riggs , pgsql-hackers@postgresql.org Subject: Small locking bugs in hs Date: Sun, 27 Dec 2009 20:12:32 +0100 User-Agent: KMail/1.13.0 (Linux/2.6.33-rc2-andres-dirty; KDE/4.3.85; x86_64; ; ) MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_gG7NLU6MuaW7US+" Message-Id: <200912272012.32556.andres@anarazel.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/2131 X-Sequence-Number: 152834 --Boundary-00=_gG7NLU6MuaW7US+ Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, While unlikely to cause issues two new LWLockAcquire calls use the wrong locking mode. Patch attached. Andres --Boundary-00=_gG7NLU6MuaW7US+ Content-Type: text/x-patch; charset="UTF-8"; name="0001-Use-correct-locking-at-two-functions-used-by-Hot-Sta.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Use-correct-locking-at-two-functions-used-by-Hot-Sta.patch" =46rom e70524baa7399972e51345d81b50377d7f15196d Mon Sep 17 00:00:00 2001 =46rom: Andres Freund Date: Sun, 27 Dec 2009 17:28:39 +0100 Subject: [PATCH 1/2] Use correct locking at two functions used by Hot Stand= by - while not likely to cause issues in reality its better to be correct. =2D-- src/backend/storage/ipc/procarray.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/= procarray.c index 85f14f6..8e2de35 100644 =2D-- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -1648,7 +1648,7 @@ GetConflictingVirtualXIDs(TransactionId limitXmin, Oi= d dbOid, errmsg("out of memory"))); } =20 =2D LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); + LWLockAcquire(ProcArrayLock, LW_SHARED); =20 /* * If we don't know the TransactionId that created the conflict, set @@ -1710,7 +1710,7 @@ CancelVirtualTransaction(VirtualTransactionId vxid, i= nt cancel_mode) int index; pid_t pid =3D 0; =20 =2D LWLockAcquire(ProcArrayLock, LW_SHARED); + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); =20 for (index =3D 0; index < arrayP->numProcs; index++) { =2D-=20 1.6.5.12.gd65df24 --Boundary-00=_gG7NLU6MuaW7US+--