Re: Bug: mdunlinkfiletag unlinks mainfork seg.0 instead of indicated fork+segment

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: Bug: mdunlinkfiletag unlinks mainfork seg.0 instead of indicated fork+segment
Date: 2026-07-07 17:08:59
Message-ID: c5b85d9c-5a95-45a7-83c7-5dca0d22fddf@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 21/12/2024 03:21, Matthias van de Meent wrote:
> On Sat, 21 Dec 2024 at 01:05, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>> The patch does not seem unreasonable and I'd like to help tidy this
>> up, but ... hmm, could we also consider going the other way?
>> register_unlink_segment(), mdunlinkfiletag() and the macro that
>> populates md.c's FileTag are internal to md.c, and we don't expect
>> external code to be pushing md.c SYNC_UNLINK_REQUEST requests into the
>> request queue (who would do that and what could the motivation
>> possibly be?) Doesn't feel like a supported usage to me... So my
>> question is: what bad thing would happen if we just renamed
>> register_unlink_segment() to register_unlink_tombstone() without
>> fork/seg arguments, to make it clear that it's not really a general
>> purpose unreliable segment unlink mechanism that we want anyone to
>> build more stuff on top of?
>
> I just noticed I misinterpreted the conditions in mdunlinkfork, so
> that I thought it allowed a user to pass their own forknum into
> register_unlink_segment (as that is called with the user-provided
> forknum). Instead, that branch is only taken when forknum ==
> MAIN_FORKNUM, so I think you might be right that going in the other
> direction is more desirable.
>
> In that case, something along the lines of the attached would then be
> better - it removes the fork and segno from register_unlink_segment's
> arguments (renamed to register_unlink_tombstone), and Asserts() that
> mdunlinkfiletag only receives a FileTag that contains expected values.

Renaming the function and the assertion makes sense to me. Committed to
master, thanks!

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2026-07-07 17:17:16 Re: Proposal: new file format for hba/ident/hosts configuration?
Previous Message Zsolt Parragi 2026-07-07 17:00:21 Proposal: new file format for hba/ident/hosts configuration?