Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAksG-000IFs-0C for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 08:36:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAksD-004XFz-0P for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 08:36:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAksC-004XFo-2N for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2026 08:36:25 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAksB-000000008Rt-1XLo for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2026 08:36:24 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-38dd9c6840aso4888191fa.0 for ; Thu, 09 Apr 2026 01:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775723782; cv=none; d=google.com; s=arc-20240605; b=g1R7hQ09HmUSDbysksVYDC4jvx93f8CsP8WE+EK22YaraHu660klmUYnhE1g3/9zrl 4Bs+YA1ea/xhKFzyALYVHKUc/5j7cYYN0Vf9mi5LYNXFpRkHfJEvq0Xp6OiWkeJ2z3F6 x7AFlTCKM0nYdwjUGZyuT9yRL6AuQrFVz+hH5nQjjyRaehEdtOlkxbxtxPNZ2ziuq5We NnnNKDXTu6cwnaLWOd/KDLY3QjBEmSR8K2TUPNKk1RP1QoY7KjhyOkAl/nam7uiaWLB6 zK8rRD8mH4t26YhkePVzRuNCjBpY1ouljWY9bdBwWdQ4G2Y3WwbKzM0YBY08hJc1f9yb mL8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iwgzxx/uHYw+k7z4Gft3b8WQ7zNg0pxNU5/YLBGljcQ=; fh=aRX+of6qToEzZmhW9qu7raLqfOqxSFMQ8LOnKl5tyi4=; b=i0Jjk2HG7XP/8437chJ06gvHvfjxe3vtzqUOn/xKL7HNxSYmGzCzK+p0OR5I09r81k IL536b9WhX8fW4Tsl/oyJPoe11Twrv+g10fNg7cq9DAFwXYapOYA/xUkk4zocpigeohu 21XIwb9jP9faX+0tUC4Q9cyB/4hC/HZivpXj5zfyT/g7FjJesTI9KJjAI7/tSDwPzY7+ 2RpcQmxbePUNIdwaHbwTQjjfqfEsjY6StrmifjxufqfM+IPQIwSXW3EzHsQOsNdVvZox RbYERCaB46iEaPJ8zZHuHz9LcfotZfFGYPk0eWCaUwKnmI5m6UYA/M2USHkMvMD/1oDR ulkA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1775723782; x=1776328582; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iwgzxx/uHYw+k7z4Gft3b8WQ7zNg0pxNU5/YLBGljcQ=; b=fV7rEagTvH4wxvNWxQmHbxcpc7OB1ne5c86qlA7JTFHML9nbQVWXY2dwgpuAHznFg2 Bg0G7ARdquE4aDOvP+TtISwL/IYixhmRHvI8D4Cmn/3rnqM5risWCGozO0q7HxvG6/g3 iPC7iBA0SYkgz9SKrIaZL+1bhVq3d8d81FeJvivtLAksg6Ei4t+3JJAjm/NDWPE/Djwk XApo5YJJ02MAnxqCYk/UoGMSny77dnbX/Vo7NyS8MtczMLGAiFAD1uF0C17s3Ps9GGFs YDv1S5uEQrZ/SXEnPOlTvtGMUtEINPKwVpmUIaeZsi4A4bNvnn2MpsnqTZuh0u9KBeYY Wz9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775723782; x=1776328582; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iwgzxx/uHYw+k7z4Gft3b8WQ7zNg0pxNU5/YLBGljcQ=; b=NJxDDeDrGcUDxNWUbwhVbzO88ONEiNg4bVNeLPz4/RW2vvqHuPCGs834HWi1zk2UHv lhuSLnbn73ZH0C2NdxABVbsupSy+v4WqNpDk6KUQZFUmkE2bTz2iGc16irxX4fW91tFM T9XvYTbuewcNv4gRb0H730ZA1w12sCrnxptSpkX8eIx4yYb2pb2BDtZ/JvVbcEO8wV3m sjSoYj4gUHGDk9HqLDCAbVDs+HCpm+ThnEfQVl7G8ZUiUqyN/o5iNfhlc0IGt/Z+82nj uFC2S6QLNXOTHvavlBGwol7tKM0TmCyOwHR3B/391sjOkKgrofGzbatnbUG2NosqV5u2 8X6A== X-Forwarded-Encrypted: i=1; AJvYcCWyY/eqNy6oENzwRApRPPICnH7p19k2zdDV6PuWGw7K2MEA1TfSFf8lHs4SdNZl6D80YCRT6VPiOD/oJZxD@lists.postgresql.org X-Gm-Message-State: AOJu0YwQJC+biVufzlt0tWjGr/K4gBXVFFMctA5s4HBXI6xcojDG5KSQ J3RzbL+t+Iy4mXmKEyPeyfQ+T6goEoewAwIhXaJVn2mtLyf07bAK5h2jfxUxaX3tE8SO2N5hvWH UpmPMx7v+zZuqJJatbj06zJkpGJiW5Wk8aL+5tdWE X-Gm-Gg: AeBDieuQr0qE3tONV5MTZLMfJNqZvcn3O72KuoOlpOIYuFiQppL/k5BMpOvHUhYg8KU yzEag8i1XfdNO7rbeTeI2cgXNSgkpvjMX4tPsy8ygr3as4qpD4SzlLvTKOCTDOjLTxQPgODwK3d jM3CEHCjlniqXlDNCLNZYVYaCDHnlDj9Vj6ocyXx6FIpOJRcK1zBOgqB08EiQJuVyHz5qb/sa2c 4UuVMdgbhbenn1p/nhR/WcBAA4lGPBGhrewkXaHnBQfZYjZJlC4bt3RHfF0uImO2mZ+dx4nhDAr muj3VzMqnUi7u1QmT8NKRLeOxiorF4jq6R129RmKIP+p+zwQ+rzNYW4B3v59DGePKrM= X-Received: by 2002:a05:651c:4208:b0:38d:f5c6:743f with SMTP id 38308e7fff4ca-38df5c6aa44mr54170911fa.9.1775723781480; Thu, 09 Apr 2026 01:36:21 -0700 (PDT) MIME-Version: 1.0 References: <013D63E2-5D75-492E-85FF-1D5CC0148C82@gmail.com> <499686.1759250489@sss.pgh.pa.us> <68dcd1f2.df0a0220.3300c0.f7af@mx.google.com> In-Reply-To: From: Jakub Wartak Date: Thu, 9 Apr 2026 10:36:08 +0200 X-Gm-Features: AQROBzCyG5ZJBc72s2WAud4_SGDfhwEIVSsqos9Q_GVW5LADUX4XmPEoLwL0bcI Message-ID: Subject: Re: The ability of postgres to determine loss of files of the main fork To: Arseniy Mukhin Cc: Michael Banck , Tom Lane , Aleksander Alekseev , Frits Hoogland , pgsql-hackers@lists.postgresql.org, "Andrey M. Borodin" , Robert Haas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Oct 1, 2025 at 12:08=E2=80=AFPM Arseniy Mukhin wrote: > > Hi, > > On Wed, Oct 1, 2025 at 10:02=E2=80=AFAM Michael Banck wr= ote: > > > > Hi, > > > > wow, this is one of the most terrifying threads I've ever seen... > > > > On Tue, Sep 30, 2025 at 12:41:29PM -0400, Tom Lane wrote: > > > Aleksander Alekseev writes: > > > >> Therefore, I would like to request an enhancement: add an option t= o > > > >> verify_heapam() that causes the primary key index to be scanned an= d makes > > > >> sure that all line pointers in the index point to existing tuples. > > > > > > > ... IMO there is little value in adding a check for the existence o= f > > > > the segments for a single table. And the *real* check will not diff= er > > > > much from something like SELECT * FROM my_table, or from making a > > > > complete backup of the database. > > > > > > As Frits mentioned, neither of those actions will really notice if a > > > table has been truncated via loss of a segment. > > > > Is there a valid case for a missing segment? If not, couldn't this be > > caught somewhere in the storage manager? > > > > > However, I think the requested functionality already exists via > > > contrib/amcheck (see the heapallindexed option). > > > > It doesn't balk for me, am I doing something wrong? > > > > |mbanck@mbanck-lin-1:~$ psql -c "SELECT COUNT(*) FROM pgbench_accounts" > > | count > > |---------- > > | 20000000 > > |(1 row) > > | > > |mbanck@mbanck-lin-1:~$ rm /tmp/pg_virtualenv.h8ObRG/data/18/regress/ba= se/5/16462.1 > > |mbanck@mbanck-lin-1:~$ ls /tmp/pg_virtualenv.h8ObRG/data/18/regress/ba= se/5/16462* | grep -v 16462_ > > |/tmp/pg_virtualenv.h8ObRG/data/18/regress/base/5/16462 > > |/tmp/pg_virtualenv.h8ObRG/data/18/regress/base/5/16462.2 > > |mbanck@mbanck-lin-1:~$ psql -c "SELECT COUNT(*) FROM pgbench_accounts" > > | count > > |--------- > > | 7995392 > > |(1 row) > > | > > |mbanck@mbanck-lin-1:~$ /usr/lib/postgresql/18/bin/pg_amcheck -v --heap= allindexed -t pgbench_accounts > > |pg_amcheck: including database "postgres" > > |pg_amcheck: in database "postgres": using amcheck version "1.5" in sch= ema "public" > > |pg_amcheck: checking heap table "postgres.public.pgbench_accounts" > > |pg_amcheck: checking btree index "postgres.public.pgbench_accounts_pke= y" > > |mbanck@mbanck-lin-1:~$ echo $? > > |0 > > |mbanck@mbanck-lin-1:~$ /usr/lib/postgresql/18/bin/pg_amcheck -v --heap= allindexed -i pgbench_accounts_pkey > > |pg_amcheck: including database "postgres" > > |pg_amcheck: in database "postgres": using amcheck version "1.5" in sch= ema "public" > > |pg_amcheck: checking btree index "postgres.public.pgbench_accounts_pke= y" > > |mbanck@mbanck-lin-1:~$ echo $? > > |0 > > |mbanck@mbanck-lin-1:~$ > > I tried to repeat it and has the same results with bt_index_check(). > IIUC the reason amcheck doesn't show any corruption here is that > allheapindexed check just builds bloom filter for all index tuples and > then test every heap tuple against it. So we actually never check that > every index tuple points to the existing segment/page/heap_tuple here. So for the sake of archives and interested people, if one wants to discover such conditions (using amcheck), please take a look on nearby more recent thread [0] where Andrey attempts to add bloom build functionality for heap (index-all-keys-match) and specifically [1] where I try to test&enhance It seems to me that checking for checking for itup's heap block pointing outside current heap max size seems enough to discover such condition reported here (but of course Andrey's attempt is much more advanced than just that). -J. [0] - https://www.postgresql.org/message-id/432626F9-65DF-4F0D-B345-26CFC3E= 2CFAC%40yandex-team.ru [1] - https://www.postgresql.org/message-id/CAKZiRmwCT%3DpqesAjC4-2rRLWQ2ui= BkrmJBhWeTgALn6yfqbuew%40mail.gmail.com