pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Patrick Stählin <patrick.staehlin@aiven.io>
To: Ronan Dunklau <ronan.dunklau@aiven.io>
To: Noah Misch <noah@leadboat.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: Re: FSM Corruption (was: Could not read block at end of the relation)
Date: Wed, 6 Mar 2024 11:59:43 +0100
Message-ID: <aede09f6-be0c-e10b-6a4f-c8e021a014c9@aiven.io> (raw)
In-Reply-To: <1958756.PYKUYFuaPT@aivenlaptop>
References: <VtPLBUerbMM8BSDLQwIMV9Co_38iHS1TXE4V09x2ZVFhPkZMNE8LwgPSIzB8PHkVFXykGx04QNAzZVjJFAnU1w==@protonmail.internalid>
	<TlHm41R71dghOEOJPrzhuxhrDI1R50MRIXHcVzU9BuJpSPKXypIYH9m5BrdxSGM_tE3DlXKFXLesUnd7vR1pxg==@protonmail.internalid>
	<3609363.R56niFO833@aivenlaptop>
	<1958756.PYKUYFuaPT@aivenlaptop>

On 3/6/24 10:31, Ronan Dunklau wrote:
> Le mardi 5 mars 2024, 00:05:03 CET Noah Misch a écrit :
>> I would guess this one is more risky from a performance perspective, since
>> we'd be adding to a hotter path under RelationGetBufferForTuple().  Still,
>> it's likely fine.
> 
> I ended up implementing this in the attached patch. The idea is that we detect
> if the FSM returns a page past the end of the relation, and ignore it.
> In that case we will fallback through the extension mechanism.

@@ -582,7 +583,17 @@ RelationGetBufferForTuple(Relation relation, Size len,
  		 * We have no cached target page, so ask the FSM for an initial
  		 * target.
  		 */
+		nblocks = RelationGetNumberOfBlocks(relation);
  		targetBlock = GetPageWithFreeSpace(relation, targetFreeSpace);

I'd move the fetching of nblocks to after getting the targetBlock. This 
avoids extending the relation in the unlikely event of a FSM/relation 
extension in-between those two calls.

Patrick





view thread (32+ messages)  latest in thread

Message-ID: <aede09f6-be0c-e10b-6a4f-c8e021a014c9@aiven.io>
Permalink:  ../aede09f6-be0c-e10b-6a4f-c8e021a014c9@aiven.io/
Also on:    postgresql.org/message-id/aede09f6-be0c-e10b-6a4f-c8e021a014c9@aiven.io

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: patrick.staehlin@aiven.io, ronan.dunklau@aiven.io, noah@leadboat.com, michael@paquier.xyz, pgsql-bugs@lists.postgresql.org
  Subject: Re: FSM Corruption (was: Could not read block at end of the relation)
  In-Reply-To: <aede09f6-be0c-e10b-6a4f-c8e021a014c9@aiven.io>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox