Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0kW5-0000yI-5i for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Oct 2017 08:31:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e0kW4-00046c-1u for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Oct 2017 08:31:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e0kW1-00044A-1Y for pgsql-hackers@postgresql.org; Sat, 07 Oct 2017 08:31:21 +0000 Received: from smtprelay0224.b.hostedemail.com ([64.98.42.224] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e0kVs-00066S-IG for pgsql-hackers@postgresql.org; Sat, 07 Oct 2017 08:31:20 +0000 Received: from filter.hostedemail.com (10.5.19.248.rfc1918.com [10.5.19.248]) by smtprelay01.b.hostedemail.com (Postfix) with ESMTP id 6E1772D2A12; Sat, 7 Oct 2017 08:31:09 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,alvherre@alvh.no-ip.org,:::::::::::,RULES_HIT:41:355:379:599:800:871:960:965:967:973:982:988:989:1260:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1535:1541:1575:1594:1595:1596:1711:1730:1747:1764:1777:1792:2393:2525:2553:2560:2563:2682:2685:2859:2933:2937:2939:2942:2945:2947:2951:2954:2987:3022:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4390:4605:5007:6117:6119:6261:6748:7281:7903:7909:8700:9025:9121:10004:10400:10450:10455:10848:11232:11604:11658:11914:12050:12296:12663:13180:13229:13439:13894:13895:14181:14658:14721:19904:19999:21080:21324:21627:30029:30054:30064:30070:30080:30089:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:4,LUA_SUMMARY:none X-HE-Tag: fang86_9f9172aa6f56 X-Filterd-Recvd-Size: 6581 Received: from alvin.alvh.no-ip.org (unknown [109.131.231.247]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf08.b.hostedemail.com (Postfix) with ESMTPA; Sat, 7 Oct 2017 08:31:08 +0000 (UTC) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id EBDF543B; Sat, 7 Oct 2017 10:31:06 +0200 (CEST) Date: Sat, 7 Oct 2017 10:31:06 +0200 From: Alvaro Herrera To: Peter Geoghegan Cc: "Wong, Yi Wen" , "Wood, Dan" , Michael Paquier , PostgreSQL Hackers , Robert Haas Subject: Re: [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple Message-ID: <20171007083106.crbmf7acrlhdb62k@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="67ro7alaqmuvhwg2" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --67ro7alaqmuvhwg2 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Peter Geoghegan wrote: > On Fri, Oct 6, 2017 at 2:09 PM, Wong, Yi Wen wrote: > > Yesterday, I've been spending time with pg_visibility on the pages when I reproduce the issue in 9.6. > > None of the all-frozen or all-visible bits are necessarily set in problematic pages. > > Since this happened yesterday, I assume it was with an unfixed version? > > As you must have seen, Alvaro said he has a variant of Dan's original > script that demonstrates that a problem remains, at least on 9.6+, > even with today's fix. I think it's the stress-test that plays with > fillfactor, many clients, etc [1]. I just execute setup.sql once and then run this shell command, while :; do psql -e -P pager=off -f ./repro.sql for i in `seq 1 5`; do psql -P pager=off -e --no-psqlrc -f ./lock.sql & done wait && psql -P pager=off -e --no-psqlrc -f ./reindex.sql psql -P pager=off -e --no-psqlrc -f ./report.sql echo "done" done Note that you need to use pg10's psql because of the \if lines in lock.sql. For some runs I change the values to compare random() to, and originally the commented out section in lock.sql was not commented out, but I'm fairly sure the failures I saw where with this version. Also, I sometime change the 5 in the `seq` command to higher values (180, 250). I didn't find the filler column to have any effect, so I took that out. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --67ro7alaqmuvhwg2 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lock.sql" begin; values ('for key share') /*, ('') */ order by random() limit 1 \gset select pg_sleep(random() * 0.03); select id from t where id=3 :column1 ; select random() > .0 as update \gset \if :update select pg_sleep(random() * 0.03); update t set x=x+1 where id=3; \endif /* select random() > .0 as update2 \gset \if :update2 savepoint foo; update t set x=x+1 where id=3; \endif select random() > .5 as rollback_to \gset \if :rollback_to rollback to foo; \endif */ select random() > .0 as commit \gset \if :commit commit; \else rollback; \endif select pg_sleep(random() * 0.03); vacuum freeze t; --67ro7alaqmuvhwg2 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="reindex.sql" reindex index t_pkey; --67ro7alaqmuvhwg2 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="report.sql" with pages (blkno) as (select generate_series::int from generate_series(0, pg_relation_size('t')/current_setting('block_size')::int - 1)), rawpages (blkno, pg) as (select blkno, get_raw_page from pages, get_raw_page('t', blkno)), heapitems as (select blkno, heap_page_items.* from rawpages, heap_page_items(pg)) select blkno, lp, lp_flags, lp_off, t_xmin, t_xmax, t_ctid, infomask(t_infomask, 1) as infomask, infomask(t_infomask2, 2) as infomask2 from heapitems where lp_off <> 0 --67ro7alaqmuvhwg2 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="repro.sql" drop table t; create table t (id int primary key, name char(3), x integer) -- with (fillfactor = 10) ; insert into t values (1, '111', 0); insert into t values (3, '333', 0); --67ro7alaqmuvhwg2 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="setup.sql" create type infomask_bit_desc as (mask varbit, symbol text); create or replace function infomask(msk int, which int) returns text language plpgsql as $$ declare r infomask_bit_desc; str text = ''; append_bar bool = false; begin for r in select * from infomask_bits(which) loop if (msk::bit(16) & r.mask)::int <> 0 then if append_bar then str = str || '|'; end if; append_bar = true; str = str || r.symbol; end if; end loop; return str; end; $$ ; create or replace function infomask_bits(which int) returns setof infomask_bit_desc language plpgsql as $$ begin if which = 1 then return query values (x'8000'::varbit, 'MOVED_IN'), (x'4000', 'MOVED_OFF'), (x'2000', 'UPDATED'), (x'1000', 'XMAX_IS_MULTI'), (x'0800', 'XMAX_INVALID'), (x'0400', 'XMAX_COMMITTED'), (x'0200', 'XMIN_INVALID'), (x'0100', 'XMIN_COMMITTED'), (x'0080', 'XMAX_LOCK_ONLY'), (x'0040', 'EXCL_LOCK'), (x'0020', 'COMBOCID'), (x'0010', 'XMAX_KEYSHR_LOCK'), (x'0008', 'HASOID'), (x'0004', 'HASEXTERNAL'), (x'0002', 'HASVARWIDTH'), (x'0001', 'HASNULL'); elsif which = 2 then return query values (x'2000'::varbit, 'UPDATE_KEY_REVOKED'), (x'4000', 'HOT_UPDATED'), (x'8000', 'HEAP_ONLY_TUPLE'); end if; end; $$; create extension if not exists pageinspect; --67ro7alaqmuvhwg2 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --67ro7alaqmuvhwg2--