Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0zbR-0001G1-8y for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2013 19:15:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U0zbP-0001mU-BX for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2013 19:15:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0qUi-0007f2-Md for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:31:44 +0000 Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0qUa-0008BX-P3 for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:31:44 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0qUX-00064z-S1 for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:31:35 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1U0qUX-0005Q3-67 for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:31:33 +0000 Date: Thu, 31 Jan 2013 09:31:33 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7840: PostgreSQL 9.3 devel select for no key share lock bug? To: pgsql-bugs@postgresql.org From: digoal@126.com X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 7840 Logged by: digoal Email address: digoal@126.com PostgreSQL version: Unsupported/Unknown Operating system: CentOS 5.7 x64 Description:=20=20=20=20=20=20=20=20 I think there is a bug in PostgreSQL 9.3 devel version about select for no key update. there is no bitmask store for no key update info in tuple head. and when i get a no key update lock, then i use pageinspect to see the t_infomask. it's a shared lock bitmask. like this :=20 digoal=3D# begin; BEGIN digoal=3D# select * from test where id=3D1 for no key update; id=20 ---- 1 (1 row) digoal=3D# select * from heap_page_items(get_raw_page('test', 0)); lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_infomask2 | t_infomask | t_hoff | t_bits | t_oid=20 ----+--------+----------+--------+--------+--------+----------+--------+---= ----------+------------+--------+--------+------- 1 | 8160 | 1 | 28 | 1743 | 1744 | 0 | (0,1) |=20= =20=20=20 1 | 448 | 24 | |=20=20=20=20=20=20 t_infomask is 0x01c0 in htup_detail.h it's #define HEAP_XMAX_EXCL_LOCK 0x0040 /* xmax is exclusive locker */ #define HEAP_XMAX_LOCK_ONLY 0x0080 /* xmax, if valid, is only a locker */ =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 /* xmax is a shared locker */ #define HEAP_XMAX_SHR_LOCK (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK) #define HEAP_XMIN_COMMITTED 0x0100 /* t_xmin committed */ SO, it get a HEAP_XMAX_SHR_LOCK lock. but the output of pgrowlocks is FOR UPDATE. digoal=3D# begin; BEGIN digoal=3D# select * from test where id=3D1 for key share; id=20 ---- 1 (1 row) digoal=3D# select * from test where id=3D1 for share; id=20 ---- 1 (1 row) And then i start another session ,i can get a key share lock. and then get the share lock. digoal=3D# begin; BEGIN digoal=3D# select * from test where id=3D1 for key share; id=20 ---- 1 (1 row) -- this will fill the t_infomask's HEAP_XMAX_IS_MULTI bit. and then i can get a share lock . digoal=3D# select * from test where id=3D1 for share; id=20 ---- 1 (1 row) but in correct rule, another session cann't get the share lock. It's a BUG? --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs