Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mi86I-0006eZ-8G for pgsql-bugs@arkaria.postgresql.org; Wed, 03 Nov 2021 04:42:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mi86G-0008JG-D1 for pgsql-bugs@arkaria.postgresql.org; Wed, 03 Nov 2021 04:42:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mi86F-0008J5-QU for pgsql-bugs@lists.postgresql.org; Wed, 03 Nov 2021 04:42:12 +0000 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mi86B-0005WP-OH for pgsql-bugs@lists.postgresql.org; Wed, 03 Nov 2021 04:42:10 +0000 Received: by mail-ot1-x32c.google.com with SMTP id n13-20020a9d710d000000b005558709b70fso1880427otj.10 for ; Tue, 02 Nov 2021 21:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0sJ59ISA3XrRTkj1MS6tOG8Ef8xb01kqG8wG/+9tap0=; b=F9QDHCwDccR0x8zu0sYw+h/9ZDitSSgUzhMY6TAKk0lWwODXBdouRmQnHYxulYZSEq sswz3rkRIcxGJm8nAMJX5hgx4UR2zgCXS00qBevW+8A98aEjoKRRSMEkkqU4CkPJXC2t q4bEIdb2pjAFJkJR1Cjv+7lYCbdUqrUYnW06M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=0sJ59ISA3XrRTkj1MS6tOG8Ef8xb01kqG8wG/+9tap0=; b=Jfc2qrJXLf1eoKhUbeYH8IuDSml9tj8wBZVfL6qEXeuje6DNiBz/zAG80Ads9QZVNH Bve3iDtpVOc0h8Sm2jH6hqUrOckBrvAZK4lPXmQO1yLgPlT8o8u8JUjjltyWvJNGimC7 UTmhB9xs8z0gDqNOSuH64GoV/8CivWMDjhyPj1URK+8+zvjy+7l/vlSJmaxbr+wGmTMi tfBvb3MZttA63Xx9yFVt5UvwSB8eS+JQWHRygqt1zbZfEo+vGQSs8kplPMC0EoJRqNYs DNbcxzh+uMfO0UBZUfPOLBGkuTQHZ+zpedAkPOKCEAnDjcr/wKRdSebWC4mNoa/g/Y2R pG4g== X-Gm-Message-State: AOAM531aPaXx1CTdNFhCM6on4y5J7uyPn0bXiEuomjh5oEEN8MVcyEiC p1uYELOrP3lpjRAGh2yZXYHSlw== X-Google-Smtp-Source: ABdhPJwm273J8FFIu/dS4VuGmzoJxOp5AtHZvxqqEK4LPAKL3mKMVlU+KivviENr/deVmujLNJwqtA== X-Received: by 2002:a05:6830:401b:: with SMTP id h27mr29904714ots.255.1635914526953; Tue, 02 Nov 2021 21:42:06 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id r23sm265438ooh.44.2021.11.02.21.42.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Nov 2021 21:42:06 -0700 (PDT) Date: Tue, 2 Nov 2021 21:42:03 -0700 From: Noah Misch To: Sandeep Thakkar Cc: Robert Haas , Andrey Borodin , Andres Freund , CM Team , PostgreSQL mailing lists , Michael Paquier , Tom Lane , Peter Geoghegan , Semab Tariq Subject: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data Message-ID: <20211103044203.GA570491@rfd.leadboat.com> References: <20211030191919.GA355663@rfd.leadboat.com> <20211031191801.q2anckkqsbd7oow2@alap3.anarazel.de> <6A1F66DD-9A4E-4EB4-BF56-369FDBF30204@yandex-team.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="llIrKcgUOe3dCx0c" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --llIrKcgUOe3dCx0c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Nov 02, 2021 at 06:20:42AM +0530, Sandeep Thakkar wrote: > (gdb) frame 1 > > #1 0x40000000003fdc00:0 in equalTupleDescs (tupdesc1=0x60000000001f65e0, > > tupdesc2=0x60000000001fba08) > ... > (gdb) p tupdesc2->attrs[2] > > $6 = {attrelid = 27272, attname = {data = "b", '\000' }, > atttypid = 19, attstattarget = -1, attlen = 64, attnum = 3, attndims = 0, > attcacheoff = -1, atttypmod = -1, attbyval = false, attalign = 99 'c', > attstorage = 112 'p', attcompression = 0 '\000', attnotnull = false, > atthasdef = false, atthasmissing = false, attidentity = 0 '\000', > attgenerated = 0 '\000', attisdropped = false, attislocal = true, > attinhcount = 0, attcollation = 950} That looks healthy. Since gdb isn't giving line numbers, let's single-step from the start of the function and see if that is informative. Please apply the attached patch, which just adds a test file. Then run "make -C src/test/subscription check PROVE_TESTS=t/080_step_equalTupleDescs.pl" and attach src/test/subscription/tmp_check/log/regress_log_080_step_equalTupleDescs in a reply to this email. On Mon, Nov 01, 2021 at 12:01:08AM +0500, Andrey Borodin wrote: > So far I didn't come up with a clear understanding how this might happen. Agreed. > The only idea I have: > 1. It seems equalTupleDescs() got two valid pointers, probably with broken data. > 2. Maybe relation->rd_rel (alloceted just before relation->rd_att) was used incorrectly? > 3. This could happen if CLASS_TUPLE_SIZE is calculated wrong. Don't we need to MAXALIGN everything due to added sizeof(relminmxid)? > #define CLASS_TUPLE_SIZE \ > (offsetof(FormData_pg_class,relminmxid) + sizeof(TransactionId)) See the comment at overread_tuplestruct_pg_cast for the reason why I think that can't cause an actual malfunction. Still, there's some possibility of this being the explanation. --llIrKcgUOe3dCx0c Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="step-to-crash-v0.patch" diff --git a/src/test/subscription/t/080_step_equalTupleDescs.pl b/src/test/subscription/t/080_step_equalTupleDescs.pl new file mode 100644 index 0000000..efa6dbd --- /dev/null +++ b/src/test/subscription/t/080_step_equalTupleDescs.pl @@ -0,0 +1,94 @@ +# run with: make -C src/test/subscription check PROVE_TESTS=t/080_step_equalTupleDescs.pl +# email src/test/subscription/tmp_check/log/regress_log_080_step_equalTupleDescs + +use strict; +use warnings; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More tests => 1; +use IPC::Run; + +my $node = PostgreSQL::Test::Cluster->new('main'); +$node->init; +$node->start; + +my $in = ''; +my $out = ''; +my $timer = IPC::Run::timeout(180); +my $psql = $node->background_psql('postgres', \$in, \$out, $timer, + on_error_stop => 0); + +$in .= q{ +SELECT pg_backend_pid(), 'after_pid'; +}; +$psql->pump until $out =~ /^([0-9]*)\|after_pid/m; +my $pid = $1; +print "backend pid: $pid\n"; + +my $gdb_cmd_file = $node->basedir . '/commands-gdb'; +PostgreSQL::Test::Utils::append_to_file($gdb_cmd_file, q{ +b equalTupleDescs +ignore 1 9 +set logging file } . $node->basedir . q{/gdb_started.txt +set logging on +set logging off +continue +p *tupdesc1 +p *tupdesc2 +p tupdesc1->attrs[0] +p tupdesc1->attrs[1] +p tupdesc1->attrs[2] +p tupdesc2->attrs[0] +p tupdesc2->attrs[1] +p tupdesc2->attrs[2] +backtrace full +set $loopvar = 25000 +while ($loopvar--) + stepi +end +quit +}); + +my $gdb = IPC::Run::start( + [qw(gdb --batch --nx --pid), $pid, '-x', $gdb_cmd_file], + $timer); +sleep .1 while !-f $node->basedir.'/gdb_started.txt'; + +# first 28 lines of src/test/regress/sql/alter_table.sql +$in .= q{ +-- +-- ALTER_TABLE +-- + +-- Clean up in case a prior regression run failed +SET client_min_messages TO 'warning'; +DROP ROLE IF EXISTS regress_alter_table_user1; +RESET client_min_messages; + +CREATE USER regress_alter_table_user1; + +-- +-- add attribute +-- + +CREATE TABLE attmp (initial int4); + +COMMENT ON TABLE attmp_wrong IS 'table comment'; +COMMENT ON TABLE attmp IS 'table comment'; +COMMENT ON TABLE attmp IS NULL; + +ALTER TABLE attmp ADD COLUMN xmin integer; -- fails + +ALTER TABLE attmp ADD COLUMN a int4 default 3; + +ALTER TABLE attmp ADD COLUMN b name; + +ALTER TABLE attmp ADD COLUMN c text; +}; + +$in .= q{ +\q +}; +$psql->finish; +$gdb->finish; +ok(1); --llIrKcgUOe3dCx0c--