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 1q664Y-0005ai-Mf for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2023 09:00:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q664W-0007HE-MN for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2023 09:00:16 +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 1q664W-0007H4-ED for pgsql-bugs@lists.postgresql.org; Mon, 05 Jun 2023 09:00:16 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q664L-000JSP-2k for pgsql-bugs@lists.postgresql.org; Mon, 05 Jun 2023 09:00:15 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f4bdcde899so5529580e87.0 for ; Mon, 05 Jun 2023 02:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685955603; x=1688547603; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=/aJmkpptxEw3TPr6edVBHOx2pvAtevfHTJUJxGinScU=; b=oo7prmPocFfILtucqvVvFPt+t8Rwj/2E0swDfU+iQeGioHmQPAxxy3Up393jddgsNG bNdiJpsj+T4vqAvH1H3yaL/Au2wYExsK6wg7qtgMhSQrXa1rZ2RrT2hEoB5bmr52OjZD jvRYqSDAuME+gqAkXt4O45iv8segtdPr/uN/ugLjl0CHYcdb76c8PDXBgNXac2PJ4O76 5uWP6cTEb4FFXyEAbPDVTBzwIC6ZTUToxCvEGziicJT8p+4fZeRPytot+2AtrFJAPNFj JgiIl3nwvbeRMJVd98dURNggeQnk7pRE/iefFV+lwDSRJgCB69f1sGJIJHaQt5HvmljH O6gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685955603; x=1688547603; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=/aJmkpptxEw3TPr6edVBHOx2pvAtevfHTJUJxGinScU=; b=WxWsOHlEdUmwOAfGLgdk87BT4VhtkmFeNMASR5Cj2ZMyqm5r39mfSKjab+TzAdsgG5 ZIlxJlF3mDtUxF86IUrIWu0qeciVBJk/RBePJz3UaoKYxR58jz4Fes97W3w62JPl541i 8QTEAyc1knDw55WZURMZfBxoMTXilkToSwMdY5DqOojKSi1FXi1RDmP4M6Msd/N60zlT atQevE3dgca5A3sYnhTCwPvuGD6rxadUcNjUgusn/RAzWh2F+eqimZYa3C4h3d1XnFG/ 7F5unueT/WBz2EimYakY2nHnW9Gpi6YvsOhIcPXDLyGu/2Va37vN6mYIyrnfV+c7/JHQ uuEg== X-Gm-Message-State: AC+VfDwRPo/kXks404lmpmaBT8sOOI81V6OU1I2aibmsDYoRquPz0UsH w1rxPVLWCQx6zQ6IPDK3cdbdI4JbZ9k= X-Google-Smtp-Source: ACHHUZ4YNxzklo5mFjsWIii1Y8Bu5IopAdy71xoZNwLNs3gyxjUbfRgabBwGH6wJ0Bbev+1+9tsOow== X-Received: by 2002:a05:6512:6e:b0:4f6:259d:3d42 with SMTP id i14-20020a056512006e00b004f6259d3d42mr1339786lfo.3.1685955603075; Mon, 05 Jun 2023 02:00:03 -0700 (PDT) Received: from [1.0.0.7] ([178.155.22.130]) by smtp.gmail.com with ESMTPSA id 7-20020ac24847000000b004f61187363asm1058183lfy.66.2023.06.05.02.00.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 02:00:01 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------4KD3a00f8BF7gUQgELKa90SG" Message-ID: Date: Mon, 5 Jun 2023 12:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #17959: amcheck fails to find a matching index tuple for an invisible heap tuple Content-Language: en-US To: pgsql-bugs@lists.postgresql.org References: <17959-0d691c29037366ab@postgresql.org> From: Alexander Lakhin In-Reply-To: <17959-0d691c29037366ab@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------4KD3a00f8BF7gUQgELKa90SG Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 03.06.2023 22:00, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 17959 > Logged by: Alexander Lakhin > Email address: exclusion@gmail.com > PostgreSQL version: 16beta1 > Operating system: Ubuntu 22.04 > Description: > > After some DDL/transactional operations (a reproducer to follow) > pg_amcheck detects an anomaly: > btree index "regress001.pg_catalog.pg_depend_reference_index": > ERROR: heap tuple (13,35) from table "pg_depend" lacks matching index > tuple within index "pg_depend_reference_index" The operations that trigger that anomaly are as follows: my $bsession1 = $node->background_psql('regress001'); $bsession1->query_safe("create temp table t1(a int)"); my $bsession2 = $node->background_psql('regress002'); $bsession2->query_safe("begin transaction"); $bsession2->query_safe("prepare transaction 'pt1'"); $bsession1->quit; my $bsession3 = $node->background_psql('regress001'); $bsession3->query_safe("create temp table t1(a int)"); $bsession3->query_safe("vacuum t1"); $bsession2->quit; $bsession3->quit; A complete TAP test to reproduce the issue is attached. I put it in src/bin/pg_amcheck/t/, run (on master, e6a254c0d) PROVE_TESTS=t/099_pdri_error.pl make -s check -C src/bin/pg_amcheck/ and get: #   Failed test 'pg_amcheck after manipulations stdout /(?^:^$)/' #   at t/099_pdri_error.pl line 60. #                   'btree index "regress001.pg_catalog.pg_depend_reference_index": #     ERROR:  heap tuple (13,35) from table "pg_depend" lacks matching index tuple within index "pg_depend_reference_index" # ' #     doesn't match '(?^:^$)' Best regards, Alexander --------------4KD3a00f8BF7gUQgELKa90SG Content-Type: application/x-perl; name="099_pdri_error.pl" Content-Disposition: attachment; filename="099_pdri_error.pl" Content-Transfer-Encoding: 7bit use strict; use warnings; use PostgreSQL::Test::Cluster; use PostgreSQL::Test::Utils; use Test::More; my ($node, $result); $node = PostgreSQL::Test::Cluster->new('test'); $node->init; $node->append_conf('postgresql.conf', " log_connections = on log_disconnections = on autovacuum = off fsync = off max_prepared_transactions = 10 "); $node->start; $node->safe_psql('postgres', 'CREATE DATABASE regress001'); $node->safe_psql('postgres', 'CREATE DATABASE regress002'); $node->safe_psql('regress001', 'CREATE EXTENSION pageinspect'); $node->command_checks_all(['pg_amcheck', '-d', 'regress001', '--install-missing', '--heapallindexed', '--rootdescend' ], 0, [qr/^$/], [qr/^$/], 'pg_amcheck before manipulations'); my $bsession1 = $node->background_psql('regress001'); $bsession1->query_safe("create temp table t1(a int)"); my $bsession2 = $node->background_psql('regress002'); $bsession2->query_safe("begin transaction"); $bsession2->query_safe("prepare transaction 'pt1'"); $bsession1->quit; my $bsession3 = $node->background_psql('regress001'); $bsession3->query_safe("create temp table t1(a int)"); $bsession3->query_safe("vacuum t1"); $bsession2->quit; $bsession3->quit; my $pd_pages = $node->safe_psql('regress001', "SELECT pg_relation_size('pg_depend')/8192"); print("pd_pages: $pd_pages\n"); my $pd_page_13 = $node->safe_psql('regress001', "\\pset format aligned \\pset tuples_only off SELECT * FROM heap_page_item_attrs(get_raw_page('pg_depend', 13), 'pg_depend'::regclass), LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);"); print("pg_depend page 13:\n$pd_page_13"); my $pdri_pages = $node->safe_psql('regress001', "SELECT pg_relation_size('pg_catalog.pg_depend_reference_index')/8192"); print("pdri_pages: $pdri_pages\n"); for (my $i = 1; $i < $pdri_pages; $i++) { my $pdri_page = $node->safe_psql('regress001', "\\pset format aligned \\pset tuples_only off SELECT * FROM bt_page_items('pg_depend_reference_index', $i)"); print("pg_depend_reference_index page $i:\n$pdri_page"); } print($node->safe_psql('regress001', " SELECT ctid, * FROM pg_depend WHERE refclassid = 0x0a37 AND refobjid = 0x4036 AND refobjsubid = 0")); $node->command_checks_all(['pg_amcheck', '-d', 'regress001', '--heapallindexed', '--rootdescend' ], 0, [qr/^$/], [qr/^$/], 'pg_amcheck after manipulations'); ok(1); done_testing(); --------------4KD3a00f8BF7gUQgELKa90SG--