Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt2mt-0008Kc-Ph for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Feb 2019 04:01:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gt2ms-0002cd-0G for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Feb 2019 04:01:42 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt2mr-0002cW-Je for pgsql-hackers@lists.postgresql.org; Mon, 11 Feb 2019 04:01:41 +0000 Received: from mail-it1-x142.google.com ([2607:f8b0:4864:20::142]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt2mn-0000Bl-V7 for pgsql-hackers@lists.postgresql.org; Mon, 11 Feb 2019 04:01:40 +0000 Received: by mail-it1-x142.google.com with SMTP id i145so22956299ita.4 for ; Sun, 10 Feb 2019 20:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fIU8UKexZEJVWW+ldw0pngm9xu5V/5HzChyi6RvZPcQ=; b=YCY0CQQN+vfhyAwbx5SRFlhn10iTJXCSfSwPgT94dix1exrxGCfV/Z1VBFpjAUYNuw dCUDEmnaLMEReom3Criy4GIP5qetIaxUPKOCfzoIiCJXfCZhS3NLj4uv6sLmRUa6HQWl hnXXUAuvwaVEnwy8M+Vni+cgkW5k1kMzHam3jiiYEsOgoOjOQk78DsfAEfbX02rHSbDB z30J4YWSoN/fKQoSX+xXQlspnygODUqShZU82PDHbHjbcypktOHymKzKC+hAYooPgmlj N5kk8vnjh9selMMUzw9rG5hPLCMuixYfNL3kWbIIf9/tvG4BGOlgzUpwzEcmDoej5lFa QkNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fIU8UKexZEJVWW+ldw0pngm9xu5V/5HzChyi6RvZPcQ=; b=KzDjao7uoenITMbTBffSkkA/Ab8LbAu8k+xicP4Nm6pgukYpfyqOoiIWHC4rtNycJn /4ouvFmSRO14a5dB+M+bycR/L8grwMF1EAQ50eNP6ypk/6Mnh1AygguOqsXc1y6HXnFb gzJJ1ft1FXWMOjdWOytlLkiXqOLfpr2DwHo0Ha2LN3JVkPBpEFWtQslBZTRlBPQLaaJA ZPoZIw1rLD0ZkbPQELK4AoOiqnwACF9nCWia6szbeojBzPnF6PV0RSFUJPgKDLdnvjd+ 5GMfGaxGF1k68ot9hHG19nEnxXgWvldDM+LA1mVWuMopp/Mk6a5q8iYe5VVbkxOTLlXT /3qw== X-Gm-Message-State: AHQUAub6MiA5+VWvbNTJSjcIYDVWJd5iE6HoIFl8nk4dcvrrL9vkjWOn o/E1e3CFdBikxwxXGnNZ74t+jS+V+c8= X-Google-Smtp-Source: AHgI3Ia/Kgsl1wvjoqL4U9Akx8GDf80DlD4fZ6QfLbZ2PULHVEUzip53dGACltMnLirsYPTY36+vlg== X-Received: by 2002:a5d:878d:: with SMTP id f13mr19382405ion.239.1549857695984; Sun, 10 Feb 2019 20:01:35 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id e22sm3935675iol.49.2019.02.10.20.01.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 20:01:34 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id E9BDF800B9A; Sun, 10 Feb 2019 22:01:32 -0600 (CST) Date: Sun, 10 Feb 2019 22:01:32 -0600 From: Justin Pryzby To: Thomas Munro Cc: pgsql-hackers@lists.postgresql.org Subject: Re: pg11.1: dsa_area could not attach to segment Message-ID: <20190211040132.GV31721@telsasoft.com> References: <20190206062427.GX29720@telsasoft.com> <20190206063548.GZ29720@telsasoft.com> <20190206070819.GA29720@telsasoft.com> <20190206071940.GB29720@telsasoft.com> <20190207014719.GJ29720@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190207014719.GJ29720@telsasoft.com> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On Mon, Feb 11, 2019 at 11:11:32AM +1100, Thomas Munro wrote: > I haven't ever managed to reproduce that one yet. It's great you have > a reliable repro... Let's discuss it on the #15585 thread. I realized that I gave bad information (at least to Thomas). On the server where I've been reproducing this, it wasn't in an empty DB cluster, but one where I'd restored our DB schema. I think that's totally irrelevant, except that pg_attribute needs to be big enough to get parallel scan. Here's confirmed steps to reproduce initdb -D /var/lib/pgsql/test pg_ctl -c start -D /var/lib/pgsql/test -o '-c operator_precedence_warning=on -c maintenance_work_mem=1GB -c max_wal_size=16GB -c full_page_writes=off -c autovacuum=off -c fsync=off -c port=5678 -c unix_socket_directories=/tmp' PGPORT=5678 PGHOST=/tmp psql postgres -c 'CREATE TABLE queued_alters(child text,parent text); CREATE TABLE queued_alters_child()INHERITS(queued_alters); ANALYZE queued_alters, pg_attribute' # Inflate pg_attribute to nontrivial size: echo "CREATE TABLE t(`for c in $(seq 1 222); do echo "c$c int,"; done |xargs |sed 's/,$//'`)" |PGHOST=/tmp PGPORT=5678 psql postgres for a in `seq 1 999`; do echo "CREATE TABLE t$a() INHERITS(t);"; done |PGHOST=/tmp PGPORT=5678 psql -q postgres while PGOPTIONS='-cmin_parallel_table_scan_size=0' PGPORT=5678 PGHOST=/tmp psql postgres -c "explain analyze SELECT colcld.child c, parent p, array_agg(colpar.attname::text ORDER BY colpar.attnum) cols, array_agg(format_type(colpar.atttypid, colpar.atttypmod) ORDER BY colpar.attnum) AS types FROM queued_alters qa JOIN pg_attribute colpar ON to_regclass(qa.parent)=colpar.attrelid AND colpar.attnum>0 AND NOT colpar.attisdropped JOIN (SELECT *, attrelid::regclass::text AS child FROM pg_attribute) colcld ON to_regclass(qa.child) =colcld.attrelid AND colcld.attnum>0 AND NOT colcld.attisdropped WHERE colcld.attname=colpar.attname AND colpar.atttypid!=colcld.atttypid GROUP BY 1,2 ORDER BY parent LIKE 'unused%', regexp_replace(colcld.child, '.*_((([0-9]{4}_[0-9]{2})_[0-9]{2})|(([0-9]{6})([0-9]{2})?))$', '\3\5') DESC, regexp_replace(colcld.child, '.*_', '') DESC LIMIT 1"; do :; done >/dev/null & # Verify this is planning parallel workers, then repeat 10-20x. Typically fails on this server in under 10min. Sorry for the error. Justin On Wed, Feb 06, 2019 at 07:47:19PM -0600, Justin Pryzby wrote: > FYI, I wasn't yet able to make this work yet. > (gdb) print *segment_map->header > Cannot access memory at address 0x7f347e554000 > > However I *did* reproduce the error in an isolated, non-production postgres > instance. It's a total empty, untuned v11.1 initdb just for this, running ONLY > a few simultaneous loops around just one query It looks like the simultaneous > loops sometimes (but not always) fail together. This has happened a couple > times. > > It looks like one query failed due to "could not attach" in leader, one failed > due to same in worker, and one failed with "not pinned", which I hadn't seen > before and appears to be related to DSM, not DSA... > > |ERROR: dsa_area could not attach to segment > |ERROR: cannot unpin a segment that is not pinned > |ERROR: dsa_area could not attach to segment > |CONTEXT: parallel worker > | > |[2] Done while PGHOST=/tmp PGPORT=5678 psql postgres -c "SELECT colcld.child c, parent p, array_agg(colpar.attname::text ORDER BY colpar.attnum) cols, array_agg(format_type(colpar.atttypid, colpar.atttypmod) ORDER BY colpar.attnum) AS types FROM queued_alters qa JOIN pg_attribute colpar ON to_regclass(qa.parent)=colpar.attrelid AND colpar.attnum>0 AND NOT colpar.attisdropped JOIN (SELECT *, attrelid::regclass::text AS child FROM pg_attribute) colcld ON to_regclass(qa.child) =colcld.attrelid AND colcld.attnum>0 AND NOT colcld.attisdropped WHERE colcld.attname=colpar.attname AND colpar.atttypid!=colcld.atttypid GROUP BY 1,2 ORDER BY parent LIKE 'unused%', regexp_replace(colcld.child, '.*_((([0-9]{4}_[0-9]{2})_[0-9]{2})|(([0-9]{6})([0-9]{2})?))$', '\\3\\5') DESC, regexp_replace(colcld.child, '.*_', '') DESC LIMIT 1"; do > | :; > |done > /dev/null > |[5]- Done while PGHOST=/tmp PGPORT=5678 psql postgres -c "SELECT colcld.child c, parent p, array_agg(colpar.attname::text ORDER BY colpar.attnum) cols, array_agg(format_type(colpar.atttypid, colpar.atttypmod) ORDER BY colpar.attnum) AS types FROM queued_alters qa JOIN pg_attribute colpar ON to_regclass(qa.parent)=colpar.attrelid AND colpar.attnum>0 AND NOT colpar.attisdropped JOIN (SELECT *, attrelid::regclass::text AS child FROM pg_attribute) colcld ON to_regclass(qa.child) =colcld.attrelid AND colcld.attnum>0 AND NOT colcld.attisdropped WHERE colcld.attname=colpar.attname AND colpar.atttypid!=colcld.atttypid GROUP BY 1,2 ORDER BY parent LIKE 'unused%', regexp_replace(colcld.child, '.*_((([0-9]{4}_[0-9]{2})_[0-9]{2})|(([0-9]{6})([0-9]{2})?))$', '\\3\\5') DESC, regexp_replace(colcld.child, '.*_', '') DESC LIMIT 1"; do > | :; > |done > /dev/null > |[6]+ Done while PGHOST=/tmp PGPORT=5678 psql postgres -c "SELECT colcld.child c, parent p, array_agg(colpar.attname::text ORDER BY colpar.attnum) cols, array_agg(format_type(colpar.atttypid, colpar.atttypmod) ORDER BY colpar.attnum) AS types FROM queued_alters qa JOIN pg_attribute colpar ON to_regclass(qa.parent)=colpar.attrelid AND colpar.attnum>0 AND NOT colpar.attisdropped JOIN (SELECT *, attrelid::regclass::text AS child FROM pg_attribute) colcld ON to_regclass(qa.child) =colcld.attrelid AND colcld.attnum>0 AND NOT colcld.attisdropped WHERE colcld.attname=colpar.attname AND colpar.atttypid!=colcld.atttypid GROUP BY 1,2 ORDER BY parent LIKE 'unused%', regexp_replace(colcld.child, '.*_((([0-9]{4}_[0-9]{2})_[0-9]{2})|(([0-9]{6})([0-9]{2})?))$', '\\3\\5') DESC, regexp_replace(colcld.child, '.*_', '') DESC LIMIT 1"; do > > I'm also trying to reproduce on other production servers. But so far nothing > else has shown the bug, including the other server which hit our original > (other) DSA error with the queued_alters query. So I tentatively think there > really may be something specific to the server (not the hypervisor so maybe the > OS, libraries, kernel, scheduler, ??). > > Find the schema for that table here: > https://www.postgresql.org/message-id/20181231221734.GB25379%40telsasoft.com > > Note, for unrelated reasons, that query was also previously discussed here: > https://www.postgresql.org/message-id/20171110204043.GS8563%40telsasoft.com