pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Wong, Yi Wen <yiwong@amazon.com>
Cc: Wood, Dan <hexpert@amazon.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple
Date: Sat, 7 Oct 2017 10:31:06 +0200
Message-ID: <20171007083106.crbmf7acrlhdb62k@alvherre.pgsql> (raw)
In-Reply-To: <CAH2-Wzn72rWQ52p=PuZ1KLHQaGD+sGd8DoKLfsPY=xSziVukyg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Peter Geoghegan wrote:
> On Fri, Oct 6, 2017 at 2:09 PM, Wong, Yi Wen <yiwong@amazon.com> 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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

lock.sql (text/plain, 606B) download 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;
reindex.sql (text/plain, 22B) download reindex index t_pkey;
report.sql (text/plain, 480B) download 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
repro.sql (text/plain, 175B) download 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);
setup.sql (text/plain, 1.7K) download 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;

view thread (129+ messages)  latest in thread

Message-ID: <20171007083106.crbmf7acrlhdb62k@alvherre.pgsql>
Permalink:  ../20171007083106.crbmf7acrlhdb62k@alvherre.pgsql/
Also on:    postgresql.org/message-id/20171007083106.crbmf7acrlhdb62k@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, pg@bowt.ie, yiwong@amazon.com, hexpert@amazon.com, michael.paquier@gmail.com, pgsql-hackers@postgresql.org, robertmhaas@gmail.com
  Subject: Re: [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple
  In-Reply-To: <20171007083106.crbmf7acrlhdb62k@alvherre.pgsql>
  References: <CAH2-Wzn72rWQ52p=PuZ1KLHQaGD+sGd8DoKLfsPY=xSziVukyg@mail.gmail.com> <20171007083106.crbmf7acrlhdb62k@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox