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 1v3vUE-005hRK-G0 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Oct 2025 11:59:10 +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 1v3vUC-001Q8s-GR for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Oct 2025 11:59:09 +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 1v3vUC-001Q8W-62 for pgsql-hackers@lists.postgresql.org; Wed, 01 Oct 2025 11:59:08 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v3vUA-0014jh-2Y for pgsql-hackers@lists.postgresql.org; Wed, 01 Oct 2025 11:59:08 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-b3dbf11fa9eso596186166b.0 for ; Wed, 01 Oct 2025 04:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759319946; x=1759924746; darn=lists.postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=t05wGgdCAKj+HVxFCt6A0vjabvmXOKbVrTDbsVLHc6A=; b=X+sMgdzNJuUtYbvLoTNpuoCtjatVVM4ExumKqtEW5t55leAEINscHeAFuDpu0ZeFfQ 9Zfc6zDYEn/k24luBg+cUoht+ULHnTa+gGiHdiyBOufjZTBBhFOZ0hsuhlBkrVCebTsm /APT9FxAcW31jasod4payikkMhPUlqQ6hkMHCHMnnPef7N99/6RovvmD0kj56TEXe/IV UKivOtwFxlMKxaW7B3r7hNBzzrBbOxpW41dDcNQhfomDkkhC0N9fb4yT+fxiBXo67Mkj 0ZnmUYZa4x1XmRJFfYaBa6TFtfaAv65WFttIYvRHcb/1Tnk8xeJDh8VBdEytm3eGrC1s OmKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759319946; x=1759924746; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t05wGgdCAKj+HVxFCt6A0vjabvmXOKbVrTDbsVLHc6A=; b=jTc68CASOvNA4NGnmqcEzhDOYd27alNT0WfsC/luM3sfJxKGJ4+YFs2+xKEWALISid Ss0L9VxkljXUHMUFnMJJlhX5LL2ALhqUBil6Hq1082Bj3BhMk+r3bcPCUJ4hZ1eC4ftE P2jCEGi5/x9I8cISWWwFQNv01jT0J/E2Itn2yfwlK76l8vN3NhnA4dK7hecvepWarewW UR0GBxvi1MQL/63MLKPlg4TWIj7+5yGqYEA4EgLOg1nvFYGYoaUzz14FiZU1eNprh2HW MkM6wXQ253pkIUSqHhY8IA7oxYIp3IRkZdYBQvOV/anE4x9/aIR87C79iwp4SbO8O+7R uL1Q== X-Gm-Message-State: AOJu0YyYx02OhswiYF/FQvgd8Cn0FJ42SgQWpXt2te0PpFAwrCofK+0H ctjGl5kqp2sIpK15+HGMYdEa/jb7K3sWSVAgUfN5X0LzV0r74WooynuE X-Gm-Gg: ASbGncsqvKfMgLwwCtw92uwwiQpJ8MX8KiFBiEXv+bjrbkxh60LQPXSnD4ZRPwpq468 o/C/pWnalXnnH8wxPt8DAStSPlau4To8845DxEmOMg6FIdbkW3sLCp/gXZEKNdXp6a9w6uP8Y1O MbxK6GsDSnIwCq/yiZaCjstARRZ3VgTQ1yfldUcRjPqY5JWc19D1jbdaT7zsR62ZOUTD3Vh/Jiz uvV1OW3CpqkMTsKFWX5IyzIRKZVgufJ+rB7ddefKhcJbx21hbPJJMp4GLOby6gBgTB+oPS47TBz 6LW05NwtOfR76tlUfKSqkOkUUPdqJtd89RJz8Ismi2Vl5njQVEzL0rG2pQgl2bHPy97k9R0DFAM QOVPWc/l1wXiRbtaDtbbazd427gan4DXTvFpq4XtnG1D18dK8fxLAcmsDhQXWkb1kR6XMgpCc5Z H/XNELHs/SSgpPLxE/Tj6VADURgVRRcaCKMijbhDUkZF9CSgNmRRhmdaUXkyv8Vkbem7S/InH7P seYlikZ4G3kLwA= X-Google-Smtp-Source: AGHT+IHO1F27thqFzsY6eNju8+mLpxgiJwB1mmFG3HbEgND3Tg/rckLVV08+ndNIdBHS+qE4rIekJQ== X-Received: by 2002:a17:907:3f98:b0:b3f:e1e9:22c1 with SMTP id a640c23a62f3a-b46e7100013mr398367666b.53.1759319945726; Wed, 01 Oct 2025 04:59:05 -0700 (PDT) Received: from smtpclient.apple (2001-1c04-0681-7700-b92f-1913-bb55-ff37.cable.dynamic.v6.ziggo.nl. [2001:1c04:681:7700:b92f:1913:bb55:ff37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b3b74cb1e9asm882143366b.98.2025.10.01.04.59.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Oct 2025 04:59:05 -0700 (PDT) From: Frits Hoogland Message-Id: <483AD9AA-39C1-4F4B-B0D6-4CBA0014E877@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_FC3CC28F-4B00-4A0C-8D17-AA21B2ECC544" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.100.1.1.5\)) Subject: Re: The ability of postgres to determine loss of files of the main fork Date: Wed, 1 Oct 2025 13:58:54 +0200 In-Reply-To: <45b3a1dd6be28dd409850a5503c029a97ca0754e.camel@cybertec.at> Cc: pgsql-hackers@lists.postgresql.org To: Laurenz Albe , Aleksander Alekseev References: <013D63E2-5D75-492E-85FF-1D5CC0148C82@gmail.com> <45b3a1dd6be28dd409850a5503c029a97ca0754e.camel@cybertec.at> X-Mailer: Apple Mail (2.3864.100.1.1.5) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_FC3CC28F-4B00-4A0C-8D17-AA21B2ECC544 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I am proposing the database to have the ability to detect when it has = missing segments. One of the main and basic properties of a database is to store data = consistently and reliably. If the database cannot detect that is missing things, this is a huge = breach to safety and reliability. And you're right that other things can be checked, this is just about = this single ability. Like Laurenz says, that other checks could possibly be done is not a = reason not to look or consider this. Laurenz makes the right assumption about my message, and sorry to = suggest an emphasis on a primary key for doing the check. A primary key has a high chance of existing, and = must contain all table rows pretty much guaranteed, and therefore is a good candidate for validating the table, = but this is really just a practical way to be able to check if a table has all its segments available = without requiring changes to the catalog. My aim actually is to point out this, what I think, is an omission, = where we are missing out. I don't know what would fit best in the current engine, my suggestion is = to keep track of segments, or the last page that contains data and thus should be available, so that metadata = is available to allow the database to be able to validate if the main fork and all segments are available. Frits Hoogland > On 1 Oct 2025, at 08:26, Laurenz Albe = wrote: >=20 > On Tue, 2025-09-30 at 18:55 +0300, Aleksander Alekseev wrote: >>> 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. >>=20 >> I'm a bit puzzled by your emphasis on primary keys. In Postgres it is >> legal to have tables without PKs, indexes, or even columns: >>=20 >> =3D# create table my_table(); >> =3D# select * from my_table; >>=20 >> To clarify, are you proposing not to check such tables? >=20 > If there is no index on a table, there is no way to determine a = missing > segment. I don't think that Frits deliberately wants to *not* check > such tables, it's just that there is no way to do it as things are = now. >=20 > Just because a check is not possible in certain cases is no good = reason > to forgo a check in those cases where it is possible. >=20 > Yours, > Laurenz Albe --Apple-Mail=_FC3CC28F-4B00-4A0C-8D17-AA21B2ECC544 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii I am proposing the database to have the = ability to detect when it has missing segments.
One of the main and = basic properties of a database is to store data consistently and = reliably.
If the database cannot detect that is missing = things, this is a huge breach to safety and = reliability.

And you're right that other things = can be checked, this is just about this single ability.
Like = Laurenz says, that other checks could possibly be done is not a reason = not to look or consider this.

Laurenz makes the = right assumption about my message, and sorry to suggest an emphasis on a = primary key
for doing the check. A primary key has a high = chance of existing, and must contain all table rows pretty = much
guaranteed, and therefore is a good candidate for = validating the table, but this is really just a practical
way = to be able to check if a table has all its segments available without = requiring changes to the catalog.

My aim = actually is to point out this, what I think, is an omission, where we = are missing out.
I don't know what would fit best in the = current engine, my suggestion is to keep track of segments, or the = last
page that contains data and thus should be available, so = that metadata is available to allow the database
to be able to = validate if the main fork and all segments are = available.


Frits = Hoogland




On 1 Oct 2025, at 08:26, Laurenz = Albe <laurenz.albe@cybertec.at> wrote:

On Tue, 2025-09-30 at = 18:55 +0300, Aleksander Alekseev wrote:
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.

I'm = a bit puzzled by your emphasis on primary keys. In Postgres it = is
legal to have tables without PKs, indexes, or even = columns:

=3D# create table my_table();
=3D# select * from = my_table;

To clarify, are you proposing not to check such = tables?

If there is no index on a table, there is no = way to determine a missing
segment.  I don't think that Frits = deliberately wants to *not* check
such tables, it's just that there = is no way to do it as things are now.

Just because a check is not = possible in certain cases is no good reason
to forgo a check in those = cases where it is possible.

Yours,
Laurenz = Albe

= --Apple-Mail=_FC3CC28F-4B00-4A0C-8D17-AA21B2ECC544--