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

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: 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: Bug: mdunlinkfiletag unlinks mainfork seg.0 instead of indicated fork+segment
Date: 2024-12-20 22:41:16
Message-ID: CAEze2WiWt+9+OnqW1g9rKz0gqxymmt=oe6pKAEDrutdfpDMpTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I noticed that the MD smgr internals misbehave when unlink requests
for specific forks or specific segments are sent through SyncOps, as
it currently always unlinks segment 0 of the main fork, even if only a
different fork and/or segment was requested.

While probably not extremely critical, it seems bad to not unlink the
right segment while in recovery, so here's a patch that unlinks the
exact requested files.

The unlinking of forks in the FileTag infrastructure has been broken
since b0a55e43 in PG16, while a segment number other than 0 has never
been unlinked (at least not since the introduction of the system with
3eb77eba in PG12). However, extensions may still make use of this and
incorrectly assume that only the requested file of the requested fork
's segment will be unlinked, when it actually unlinks data from the
main fork.

The attached fixes that for PG16+. PG13-15 will take a little bit more
effort due to code changes in PG16; though it'd probably still require
a relatively minor change.

Kind regards,

Matthias van de Meent.
Neon (https://neon.tech)

Attachment Content-Type Size
v1-0001-MD-smgr-Unlink-the-requested-file-segment-not-mai.patch application/octet-stream 2.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-12-20 22:45:43 Re: Discussion on a LISTEN-ALL syntax
Previous Message David G. Johnston 2024-12-20 22:23:31 Re: Discussion on a LISTEN-ALL syntax