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 1mXWZE-000845-RA for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Oct 2021 22:36:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXWZD-0007PR-MB for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Oct 2021 22:36:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXWZD-0007PJ-4F for pgsql-hackers@lists.postgresql.org; Mon, 04 Oct 2021 22:36:15 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mXWZ9-0003k3-7G for pgsql-hackers@postgresql.org; Mon, 04 Oct 2021 22:36:14 +0000 Received: by mail-pf1-x429.google.com with SMTP id p1so9667232pfh.8 for ; Mon, 04 Oct 2021 15:36:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=07dfHWw1aGY5kAp6G+f5VUxEG4PQNEXnAzgNr+W0f6c=; b=c94pEJFyb980Vm5Q3Ho8T/gkQuYk6TaC6lfT/I6Bo/3/Us5b6i81OAYp0WReX5vUgU UXzieAXaZbSrhMTpqKKv3xDo84CIwhbZqZW+Uz1Zz7ZVvwf3+wVR7ojAECBx+jddm0JQ uFt6A0XJfQaIvP5qt6BY8LG39feOUFxTgmjNFrW7o9xiyJGV57uIede+RIIbYzFaDWrT V/gix2UUjcbkUHnt/VEPbs+Dzi36q92Lamars1uYg3HdnQwM2cFR0sBrkSxs6fndy5fg jeRwkcdBKKRHNPRbFCRiqVFEVJzQJcwcC3CZsVWGp/W9ADbTu8thT2lc/+29PjsOR0jV smmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=07dfHWw1aGY5kAp6G+f5VUxEG4PQNEXnAzgNr+W0f6c=; b=6Cc2TrIJZoDth8pLIqUoA42oF7Jp9CbhXg00vuZ3mzSEK8vJSpxjds6rsJYGpjLot2 +Qw+QTVPlMvrmyApVaEpjER6Uht0/JvXga0F4fewyGj8qPyUst3TiS6eZ73Eg0j5OHZe EvX8RHhn1FmM2WHZz0COdm9TbFboeZMM6ZUD5qbUuiOLfV02UQmTRuANF31jq+QCDmty gNOsOHPgG/EZQSczd4SS76kfYhzBBsmLZf067IYqct08fKKlBtaH7QehvU+d/iJsx+9H CV5qAI6g2rE+u1BA02HKAkJ6yHHbDjmme7M3yqTom2cwasoEK6F8BoF+sQwFWUMAg/Ut CB7A== X-Gm-Message-State: AOAM532oqopjIVjsqA5uV46MXww2MokMinVnHzn2yxKw3/501VMXr6WE ZVjua0jAToHfLVYyWyi8KgY/07scn7uWB4N6BzTXrG9RACWzN6oYOKYEIGkzlYRpA/XDkpeK8f1 vycSR1v8bqqge+CpJb4ugbX2i7pLtgRm1ult/hnumLFPdiBt0mRRdHqy6rGKwB4tr+vWLmABWl6 8OrN1XR+XwIGWE5SrM+h3Lr2/YMHCjJNhB+/gg X-Google-Smtp-Source: ABdhPJxuFQhD2F6ACeMictua2KMDoeEX+uwq36H8C/7OrVVhvY1E5YMikA88e3MxEkW8NutkVBqkXQ== X-Received: by 2002:a05:6a00:2389:b0:44c:434:6c5d with SMTP id f9-20020a056a00238900b0044c04346c5dmr24070808pfc.29.1633386968654; Mon, 04 Oct 2021 15:36:08 -0700 (PDT) Received: from laptop280-ma-us.hitronhub.home (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id h4sm15005640pgn.6.2021.10.04.15.36.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Oct 2021 15:36:08 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: BUG #17212: pg_amcheck fails on checking temporary relations From: Mark Dilger In-Reply-To: Date: Mon, 4 Oct 2021 15:36:06 -0700 Cc: Alexander Lakhin , PostgreSQL-development , Robert Haas Content-Transfer-Encoding: quoted-printable Message-Id: <386F66EE-DEFD-42EA-9DB2-102BF3414669@enterprisedb.com> References: <17212-34dd4a1d6bba98bf@postgresql.org> <28B36E41-1E8F-4DC1-A924-711621BA4972@enterprisedb.com> To: Peter Geoghegan X-Mailer: Apple Mail (2.3608.120.23.2.7) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Oct 4, 2021, at 10:58 AM, Peter Geoghegan wrote: >=20 > On Mon, Oct 4, 2021 at 8:10 AM Mark Dilger = wrote: >>> There is another issue, that maybe should be discussed separately = (or >>> this thread could be renamed to "... on checking specific = relations"), >>> but the solution could be similar to that. >>> pg_amcheck also fails on checking invalid indexes, that could be = created >>> legitimately by the CREATE INDEX CONCURRENTLY command. >>=20 >> I believe this is a bug in amcheck's btree checking functions. = Peter, can you take a look? >=20 > Why do you say that? Because REINDEX CONCURRENTLY and the bt_index_parent_check() function = seem to have lock upgrade hazards that are unrelated to pg_amcheck. > This hasn't been a > problem before now, probably because the sample verification query in > the docs (under bt_index_check()) accounts for this directly. It doesn't say anything about deadlocks, but yes, it mentions errors = will be raised unless the caller filters out indexes that are invalid or = not ready. On to pg_amcheck's behavior.... I see no evidence in the OP's complaint that pg_amcheck is misbehaving. = It launches a worker to check each relation, prints for the user's = benefit any errors those checks raise, and finally returns 0 if they all = pass and 2 otherwise. Since not all relations could be checked, 2 is = returned. Returning 0 would be misleading, as it implies everything was = checked and passed, and it can't honestly say that. The return value 2 = does not mean that anything failed. It means that not all checks = passed. When a 2 is returned, the user is expected to read the output = and decide what, if anything, they want to do about it. In this case, = the user might decide to wait until the reindex finishes and check = again, or they might decide they don't care. It is true that pg_amcheck is calling bt_index_parent_check() on an = invalid index, but so what? If it chose not to do so, it would still = need to print a message about the index being unavailable for checking, = and it would still have to return 2. It can't return 0, and it is = unhelpful to leave the user in the dark about the fact that not all = indexes are in the right state for checking. So it would still print = the same error message and still return 2. I think this bug report is really a feature request. The OP appears to = want an option to toggle on/off the printing of such information, = perhaps with not printing it as the default.=20 =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company