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 1mXYOF-0004hM-Vt for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Oct 2021 00:33:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXYOE-0005va-Jg for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Oct 2021 00:33:02 +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 1mXYOD-0005vR-Ts for pgsql-hackers@lists.postgresql.org; Tue, 05 Oct 2021 00:33:02 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mXYO9-000506-D8 for pgsql-hackers@postgresql.org; Tue, 05 Oct 2021 00:33:00 +0000 Received: by mail-pj1-x102d.google.com with SMTP id ls18-20020a17090b351200b001a00250584aso174481pjb.4 for ; Mon, 04 Oct 2021 17:32:57 -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=61uuY6w0tif+qmGwT4Fp+gqHtXQi4FXavGdcekzrh+0=; b=dt8DNYN+DAAdwVkfBRp1UiaETQgYF1iAppWGhe/Dcbaq36bkIYgpWzLLarjLvo5PV1 7eC0qIbrneljx5DHrQh4d3S3UZbTvAmuYEmZNVcTFADi2bhse4CSJjYgqH65HNjC64QD XVC1cusqPMOfatR9hbyNhOUCtqDBA9a6muZBgtg+UGVzuURwlixYwkKjFeNCmGNM9by1 PeHP4vDAg1BJMcfQZADTU2q8v9+6e1fwesBDLPENl5wf8ApWuwEoy9sOoseVE1wjTYRA wjrPeMWsWIpNKBLowP59azfouAB8jjsT32rSdwwAYcRFgk61fpPxHPmdO4k2hSKES2N0 2+0A== 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=61uuY6w0tif+qmGwT4Fp+gqHtXQi4FXavGdcekzrh+0=; b=gKvwBxAeynDdjgJGd8m9svy/4v06U4M5UnDVv3aUth6AdxMSvZIhsFUNc/RpUcd0Zc 3AdilzDydEJrD97qSXahrQIwpSK2UUbRdq0++mtQb/S85pOFmYbvK8tanuOKUSP1ZeJq rQ6VkINbSdIMf0OWyRfWhwEqrTaXu/xg7m1AMzLOlOONuetxXFAc8jYt0u0mtQ9jUVqe 7FMgltVQDxfZ/FYwYNB0CcHIrpuV7oUAxtaPq8H6E0F16Ce9gEu4JksNlwWQKijeULOB lSN9TYsQRtNTZvLSNYpyIv3o45wxPdJUqW61Bwu1QfUwD9i7MWtehH24hNcn0Djc6gTm mTaA== X-Gm-Message-State: AOAM530HU8lr+oRswuOXx09UD2H5/M0Sp/z7BNqwwW+r55Aq8QFkrdbW YAW1/GMnaN29mZ28MvQL7Zgf6DnWJSeI65O4oC+VjwJ1Jn8hlptGyaGT0/+N7oN+FpaQ6eU1IZl cSaTwpieMI7aHJeyq9I0rzU1HImu2+o/t0dE6Rc9SWOY2qH9QKDiTL4e0HzfYXVecWB4YJo6tu5 nM9jZQk2Aa6rXXtJ5kzGwovN8z/fWm7PTf/R3N X-Google-Smtp-Source: ABdhPJyRdK5+c7kn7ZCHcCXKfwj3KCTkhPr5cGO6lm25IkSEmBPCQR3/7VORx85UkwzyAnFlKGoQaQ== X-Received: by 2002:a17:90b:3844:: with SMTP id nl4mr169390pjb.168.1633393975570; Mon, 04 Oct 2021 17:32:55 -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 w185sm12523578pfd.113.2021.10.04.17.32.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Oct 2021 17:32:55 -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 17:32:54 -0700 Cc: Alexander Lakhin , PostgreSQL-development , Robert Haas Content-Transfer-Encoding: quoted-printable Message-Id: <81019B2A-C0EB-4890-BA3A-DB60590AAF43@enterprisedb.com> References: <17212-34dd4a1d6bba98bf@postgresql.org> <28B36E41-1E8F-4DC1-A924-711621BA4972@enterprisedb.com> <386F66EE-DEFD-42EA-9DB2-102BF3414669@enterprisedb.com> <71339EFC-3060-4775-B9C6-D39E02752A2F@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 4:45 PM, Peter Geoghegan wrote: >=20 > I'm guessing that you meant REINDEX CONCURRENTLY. Yes. > Since you're talking about the case where it has an error Sorry, I realized after hitting that you might take it that way, = but I mean the logs generally, not just postgres logs. If somebody runs = "reindex concurrently" on all tables at midnight every night, and they = see one morning in the (non-postgres) logs from the midnight hour weird = error messages about their RAID controller, they may well want to check = all their indexes to see if any of them were corrupted. This is a = totally made-up example, but the idea that a user might want to check = their indexes, tables, or both owing to errors of some kind is not = far-fetched. =20 > , the whole > index build must have failed. So the user would get exactly what > they'd expect -- verification of the original index, without any > hindrance from the new/failed index. Right, in that case, but not if hardware errors corrupted the index, and = generated logs, without happening to trip up the reindex concurrently = statement itself. > (Thinks for a moment...) >=20 > Actually, I think that we'd only verify the original index, even > before the error with CONCURRENTLY (though I've not checked that point > myself). To get back on track, let me say that I'm not taking the position that = what pg_amcheck currently does is necessarily correct, but just that I'd = like to be careful about what we change, if anything. There are three = things that seem to irritate people: 1) A non-zero exit code means "not everything was checked and passed" = rather than "at least one thing is definitely corrupt". 2) Skipping of indexes is reported to the user with the word 'ERROR' in = the report rather than, say, 'NOTICE'. 3) Deadlocks can occur I have resisted changing #1 on the theory that `pg_amcheck --all && = ./post_all_checks_pass.sh` should only run the post_all_checks_pass.sh = if indeed all checks have passed, and I'm interpreting skipping an index = check as being contrary to that. But maybe that's wrong of me. I don't = know. There is already sloppiness between the time that pg_amcheck = resolves which database relations are matched by --all, --table, = --index, etc. and the time that all the checks are started, and again = between that time and when the last one is complete. Database objects = could be created or dropped during those spans of time, in which case = --all doesn't have quite so well defined a meaning. But the user = running pg_amcheck might also *know* that they aren't running any such = DDL, and therefore expect --all to actually result in everything being = checked. I find it strange that I should do anything about #2 in pg_amcheck, = since it's the function in verify_nbtree that phrases the situation as = an error. But I suppose I can just ignore that and have it print as a = notice. I'm genuinely not trying to give you grief here -- I simply = don't like that pg_amcheck is adding commentary atop what the checking = functions are doing. I see a clean division between what pg_amcheck is = doing and what amcheck is doing, and this feels to me to put that on the = wrong side of the divide. If refusing to check the index because it is = not in the requisite state is a notice, then why wouldn't verify_nbtree = raise it as one and return early rather than raising an error? I also find it strange that #3 is being attributed to pg_amcheck's = choice of how to call the checking function, because I can't think of = any other function where we require the SQL caller to do anything like = what you are requiring here in order to prevent deadlocks, and also = because the docs for the functions don't say that a deadlock is = possible, merely that the function may return with an error. I was = totally content to get an error back, since errors are how the = verify_nbtree functions communicate everything else, and the handler for = those functions is already prepared to deal with the error messages so = returned. But it clearly annoys you that pg_amcheck is doing this, so = I'll go forward with the patch that I already have written which does = otherwise. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company