Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TM34h-0003mK-0D for pgsql-hackers@postgresql.org; Wed, 10 Oct 2012 20:40:15 +0000 Received: from [2001:1528:137::f1] (helo=mail.gransy.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TM34f-0001Xw-Rc for pgsql-hackers@postgresql.org; Wed, 10 Oct 2012 20:40:14 +0000 Received: from antispam.gransy.com (antispam.gransy.com [77.78.104.124]) by mail.gransy.com (Postfix) with ESMTP id 242B7508A7F; Wed, 10 Oct 2012 22:40:12 +0200 (CEST) Received: from mail.gransy.com ([82.208.44.189]) by antispam.gransy.com (antispam.gransy.com [77.78.104.124]) (amavisd-new, port 10024) with ESMTP id cjmXT663-utN; Wed, 10 Oct 2012 22:40:12 +0200 (CEST) Received: by mail.gransy.com (Postfix, from userid 5000) id 0FC7B508A83; Wed, 10 Oct 2012 22:40:12 +0200 (CEST) Received: from [192.168.1.237] (ip-78-45-133-255.net.upcbroadband.cz [78.45.133.255]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTPSA id D49D4508A7F; Wed, 10 Oct 2012 22:40:11 +0200 (CEST) Message-ID: <5075DD2B.4040102@fuzzy.cz> Date: Wed, 10 Oct 2012 22:40:11 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: "ktm@rice.edu" CC: pgsql-hackers@postgresql.org Subject: Re: change in LOCK behavior References: <5075D8DF.6050500@fuzzy.cz> <20121010203702.GA1583@aart.rice.edu> In-Reply-To: <20121010203702.GA1583@aart.rice.edu> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:1528:137::f1 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201210/516 X-Sequence-Number: 214752 On 10.10.2012 22:37, ktm@rice.edu wrote: > On Wed, Oct 10, 2012 at 10:21:51PM +0200, Tomas Vondra wrote: >> Example: >> >> A: BEGIN; >> A: LOCK x IN ACCESS EXCLUSIVE MODE; >> A: INSERT INTO x VALUES (100); >> B: SELECT * FROM x; >> A: COMMIT; >> >> Now on 9.1, B receives the value "100" while on 9.2 it gets no rows. >> >> Is this expected? I suspect the snapshot is read at different time or >> something, but I've checked release notes but I haven't seen anything >> relevant. >> >> Without getting the commited version of data, the locking is somehow >> pointless for us (unless using a different lock, not the table itself). >> >> regards >> Tomas >> > Hi Tomas, > > 9.2 is doing it right. Per the documentation on explicit locking: > > http://www.postgresql.org/docs/9.2/static/explicit-locking.html > > Tip: Only an ACCESS EXCLUSIVE lock blocks a SELECT (without FOR UPDATE/SHARE) statement. That is not the problem. We do expect it to block (that's why we do this kind of lock in the first place), and that does happen both on 9.1 and 9.2. The difference is that 9.1 does see the changes performed in the other session (that held the lock and released it on commit), while 9.2 does not. Tomas