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.94.2) (envelope-from ) id 1v3tlT-005Jop-3c for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Oct 2025 10:08:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v3tlR-000DUe-12 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Oct 2025 10:08:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v3tlQ-000DUW-OQ for pgsql-hackers@lists.postgresql.org; Wed, 01 Oct 2025 10:08:49 +0000 Received: from mail-yx1-xb134.google.com ([2607:f8b0:4864:20::b134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v3tlP-0013e4-1T for pgsql-hackers@lists.postgresql.org; Wed, 01 Oct 2025 10:08:49 +0000 Received: by mail-yx1-xb134.google.com with SMTP id 956f58d0204a3-635349b6fe6so4990044d50.2 for ; Wed, 01 Oct 2025 03:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759313325; x=1759918125; 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=J4HjHKGJxmnrBjm9lK7oLgYt2PhS6z6xAEhTH4q/VY0=; b=VUiIrDYPwbh8x8RQMYgfRSZNxOf8JCsLoHE+LV8ZzsJ0NLMf3XInk53j0FYfJRbdfM POqEyLX4OafjceK5b0/EjvfvhV5eOlMzIlJ3qqKhpmm7xsqlmIMKvMyDLQiMHym3wURi R7+PsJdYIvurtjF7J/sPuXmkh3CnoyCd7I0qPqLDifIaYz4gElGZLnJUK36onfq5K8z9 pyVHRO5SKMKiWDu0Jui0A8ulg0Xpt26SsF5EI4xFyGYBM2JkdeOVfw3yWheRAYMuHLQg uLqjfCdlrKSc2domqnJV0SxX81dy2d03LwNKUV6BQaaYYL5NnoDjzSb8p0wJpqByC3PG ai4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759313325; x=1759918125; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J4HjHKGJxmnrBjm9lK7oLgYt2PhS6z6xAEhTH4q/VY0=; b=ewp2NPJuISeoDSbhjw4SR1AfUrm0FMugT5APffND+YHLL9YbaHkFn/m1/u/Klkd7S8 t/Fw5FRWm8QoIrdn3vs50HPxZ94lRxSvEy6bGU0R8ZD39mn1JNoLTHhv29xnV8uaPNv5 QPJM2gbRVWvTdPusRW0pBO1s3hSrB849rH6l/RdTo3/LsQWyrYm7/T8W1JN/Z2hNHALn MkqqP5Pde432ET19UYK577+EjWrBibi1JXgPSFGtQ7JvvBwwmZK9NJDWt1N2R0ykhDRT TM7s6DR0cJMKfO4wjiNIYgsT8W8V4LJeRSh8YEJCgZKF3CVT346aTH4Rhbc+5Le94zE7 liZQ== X-Forwarded-Encrypted: i=1; AJvYcCXFSZ4BYDs/IjvVp4fMxvZX3F2SFqU01cuxjsos78DZjiWvX5vblOVvkbD002MobMn2JV1wzRRXz3yew2kL@lists.postgresql.org X-Gm-Message-State: AOJu0YwCZiihRr9IlYYLZFt77rySSzsLnuTH89jIrBmmNCr5RDgCBwdB A/BBy22+zpW+g69OKRxfpedVHZZ62Iiccy27ZM1zpOlb1qIhAVa8yVCMDyvtzBJQWNOM+dcQRGn ey7MWKzU9WpcZi0kRh2eiJ89FpDvAzOo= X-Gm-Gg: ASbGncsXkVdSZXzSwlUI8pbwn2PPsko3TvNLmK6yEn6uNHJVkY7590yvngEZzBDHbOH K4QC3NlWrg+17ZL9+7VW6o+3rIU80SieBAcqsZ8101LnLqNfymfCadRLl0vFJi11wj/SpN+foBY dnmlq3lmBfC3ZwgsSDO0soZl2KUPVIv5E0m7RpcKX1Ev7KvbX3kWG4thjLNDICM753qVfWZee7p zy2XIK9E7IY4uxdO5z7aOv59XWP6J0x X-Google-Smtp-Source: AGHT+IFaXqD6wtHF8lriE/2j0G9hCESjoYRDM+gbcdLMU12B+PmlwkBhlm56x5ew1Jeu1PU+CMZNp5PTfKoYuBTjTBw= X-Received: by 2002:a53:cbcc:0:b0:635:4ecf:bdd0 with SMTP id 956f58d0204a3-63b6ff628eamr3370609d50.50.1759313325402; Wed, 01 Oct 2025 03:08:45 -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: <68dcd1f2.df0a0220.3300c0.f7af@mx.google.com> From: Arseniy Mukhin Date: Wed, 1 Oct 2025 13:08:33 +0300 X-Gm-Features: AS18NWCW1b9pL6T4keyNOR08EHVGrYax60oXbwWUOril3flSYqZQQDXb-QUYxNg Message-ID: Subject: Re: The ability of postgres to determine loss of files of the main fork To: Michael Banck Cc: Tom Lane , Aleksander Alekseev , Frits Hoogland , pgsql-hackers@lists.postgresql.org 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 Hi, On Wed, Oct 1, 2025 at 10:02=E2=80=AFAM Michael Banck wrot= e: > > 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 to > > >> verify_heapam() that causes the primary key index to be scanned and = 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 of > > > the segments for a single table. And the *real* check will not differ > > > 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/base= /5/16462.1 > |mbanck@mbanck-lin-1:~$ ls /tmp/pg_virtualenv.h8ObRG/data/18/regress/base= /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 --heapal= lindexed -t pgbench_accounts > |pg_amcheck: including database "postgres" > |pg_amcheck: in database "postgres": using amcheck version "1.5" in schem= a "public" > |pg_amcheck: checking heap table "postgres.public.pgbench_accounts" > |pg_amcheck: checking btree index "postgres.public.pgbench_accounts_pkey" > |mbanck@mbanck-lin-1:~$ echo $? > |0 > |mbanck@mbanck-lin-1:~$ /usr/lib/postgresql/18/bin/pg_amcheck -v --heapal= lindexed -i pgbench_accounts_pkey > |pg_amcheck: including database "postgres" > |pg_amcheck: in database "postgres": using amcheck version "1.5" in schem= a "public" > |pg_amcheck: checking btree index "postgres.public.pgbench_accounts_pkey" > |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. Best regards, Arseniy Mukhin