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 1mXJpR-0005h2-CK for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Oct 2021 09:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXJpQ-0002IP-CO for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Oct 2021 09:00:08 +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 1mXJpQ-0002IG-1m for pgsql-hackers@lists.postgresql.org; Mon, 04 Oct 2021 09:00:08 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mXJpN-0004m2-8g for pgsql-hackers@postgresql.org; Mon, 04 Oct 2021 09:00:07 +0000 Received: by mail-lf1-x131.google.com with SMTP id b20so68900037lfv.3 for ; Mon, 04 Oct 2021 02:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=qVWP/r4cK4BRjpfLPpwroBSQv7+ZAMPqtiVOy41krCw=; b=On17LI4YQYHKmjG8T9ZdCqTXDSoCqSIgvwczzjrxZFi5BhqfC0/cTR9UGnRtoZzGFO ksHsWmT3V8hcczpZhf4QndSeUIDK1PpqLPtj9SyHYdzDXDrV2LnZQ07nh6v5DT9lZHz1 725ygRjGD/AmeNj+QTQrTmQ4E6FaP5Jm2BV06vEEnSgdIC9eHIRD6ABieWILeLHB9Fmk /PXH9jJu6WuYlcWsffS13cYpx1nIkzV06IDI2zLb/Swl3kk9SBRAmDlSqri2v4upTXX3 4j8rRQu3S0DCuBrswidexu9E97J9QkffY0DTPkMyYyyzSPa/Wl6cnrHQebun+RhqcMFE amkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=qVWP/r4cK4BRjpfLPpwroBSQv7+ZAMPqtiVOy41krCw=; b=sotATDNwHt1Wr6qhphn6Fm/s2hsFR60ZtFSPtAQ0NALrE4u4AOaZ2Wo1Zsafam7eEf gjFHqts5z/yMyWzQT3JzNt0ICyyvxb6stvUzTwktm+fBvYoz3d5sfza8Couw3ANYtShP ukFLMRuJLtkRrbUlU6Bf1NYrFAsTTPgyjo/fbQmftXvaA4mWzjSCFnIAiI3MAhJQ7r2Z oRfzVeETw9lN6LyFlr5od9u8VweQiXWxTuGMeDN+msz9KPgLZeGQbu7N+W3BnDKBhiSY pFGfAHlnpv+TUBPDokgiHKVUIqgkPhz7zwjmFWHFD3ppkfBJtRbMDlNxmMHxKi7qY+DT Cp1w== X-Gm-Message-State: AOAM533tZPfsOADzSgfCpl4dBh5DKuyTaks8m7i9TW3luDInwab+g89P FwvsahsWLmcXxdPAEwWksunk9h8t3sY= X-Google-Smtp-Source: ABdhPJzz7MfFEfrVgpk9n95DjHsVLamdLsOeruynEPJ0hPOE+CgVpLrZOXi6as8cyWEtkyvu4D1hSw== X-Received: by 2002:a2e:5046:: with SMTP id v6mr15128513ljd.368.1633338003135; Mon, 04 Oct 2021 02:00:03 -0700 (PDT) Received: from [1.0.0.7] ([178.155.6.44]) by smtp.gmail.com with ESMTPSA id u9sm1557401lfo.44.2021.10.04.02.00.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Oct 2021 02:00:02 -0700 (PDT) Subject: Re: BUG #17212: pg_amcheck fails on checking temporary relations To: Mark Dilger , PostgreSQL-development Cc: Robert Haas , Peter Geoghegan References: <17212-34dd4a1d6bba98bf@postgresql.org> From: Alexander Lakhin Message-ID: Date: Mon, 4 Oct 2021 12:00:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Mark, 04.10.2021 01:20, Mark Dilger wrote: > The attached patch includes a test case for this, which shows the problems against the current pg_amcheck.c, and a new version of pg_amcheck.c which fixes the bug. Could you review it? > > Thanks for bringing this to my attention. 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. For example, consider the following script: psql -c "CREATE TABLE t(i numeric); INSERT INTO t VALUES (generate_series(1, 10000000));" psql -c "CREATE INDEX CONCURRENTLY t_idx ON t(i);" & pg_amcheck -a --install-missing --heapallindexed --rootdescend --progress || echo "FAIL" pg_amcheck fails with: btree index "regression.public.t_idx":     ERROR:  cannot check index "t_idx"     DETAIL:  Index is not valid. 781/781 relations (100%), 2806/2806 pages (100%) FAIL When an index created without CONCURRENTLY, it runs successfully. Beside that, it seems that pg_amcheck produces a deadlock in such a case: 2021-10-04 11:23:38.584 MSK [1451296] ERROR:  deadlock detected 2021-10-04 11:23:38.584 MSK [1451296] DETAIL:  Process 1451296 waits for ShareLock on virtual transaction 5/542; blocked by process 1451314.     Process 1451314 waits for ShareLock on relation 16385 of database 16384; blocked by process 1451296.     Process 1451296: CREATE INDEX CONCURRENTLY t_idx ON t(i);     Process 1451314: SELECT * FROM "pg_catalog".bt_index_parent_check(index := '16390'::regclass, heapallindexed := true, rootdescend := true) 2021-10-04 11:23:38.584 MSK [1451296] HINT:  See server log for query details. 2021-10-04 11:23:38.584 MSK [1451296] STATEMENT:  CREATE INDEX CONCURRENTLY t_idx ON t(i); I think that the deadlock is yet another issue, as invalid indexes could appear in other circumstances too. Best regards, Alexander