Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U10N3-0003ge-IV for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2013 20:04:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U10N2-0007b6-FF for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2013 20:04:28 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U10N1-0007b0-FY for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 20:04:27 +0000 Received: from smtprelay0216.b.hostedemail.com ([64.98.42.216] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U10Mx-0001Cp-QO for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 20:04:26 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay06.b.hostedemail.com (Postfix) with SMTP id A3DFBF6FB5; Thu, 31 Jan 2013 20:04:21 +0000 (UTC) X-Panda: scanned! X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::, RULES_HIT:69:355:379:599:601:800:945:967:973:988:989:1260:1277:1311:1312:1313:1314:1345:1358:1359:1437:1515:1516:1518:1519:1534:1542:1593:1594:1595:1596:1711:1730:1747:1777:1792:1801:2393:2525:2560:2563:2682:2685:2693:2828:2859:2895:2933:2937:2939:2942:2945:2947:2951:2954:3022:3027:3138:3139:3140:3141:3142:3151:3354:3865:3866:3868:3869:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4605:4659:5007:6261:7679:7875:7903:9025:9121:9149:10004:10400:10848:11256:11257:11473:11658:11914:12043:12438:12517:12519:12683, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Filterd-Recvd-Size: 2944 Received: from perhan.alvh.no-ip.org (unknown [190.95.28.201]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf06.b.hostedemail.com (Postfix) with ESMTPA; Thu, 31 Jan 2013 20:04:21 +0000 (UTC) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 2EC3E6E0B6; Thu, 31 Jan 2013 17:04:14 -0300 (CLST) Date: Thu, 31 Jan 2013 17:04:14 -0300 From: Alvaro Herrera To: digoal@126.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7840: PostgreSQL 9.3 devel select for no key share lock bug? Message-ID: <20130131200414.GD4883@alvh.no-ip.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: 0.3 (/) 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 digoal@126.com wrote: > 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 lock= er > */ > #define HEAP_XMAX_LOCK_ONLY 0x0080 /* xmax, if valid, is onl= y 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=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 */ >=20 > SO, it get a HEAP_XMAX_SHR_LOCK lock. but the output of pgrowlocks is FOR > UPDATE. No, this is fine actually. Notice that XMAX_SHR_LOCK needs both XMAX_EXCL_LOCK and XMAX_KEYSHR_LOCK. What 0xc0 has XMAX_EXCL_LOCK, but not XMAX_KEYSHR_LOCK -- there's XMAX_LOCK_ONLY, which is different. You're right that pgrowlocks is giving a bogus output here -- says For Update, should say For No Key Update. > 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? Hm, yeah, this is a bug. Looking. --=20 =C1lvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs