Preventing free space from being reused

From: Noah Bergbauer <noah(at)statshelix(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Preventing free space from being reused
Date: 2021-02-12 21:05:55
Message-ID: CABjy+RgC_GHW2jvpjZseq80y0KP=JXX6rV1JtpFk9M39G+_mDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I am working on a project where I do not want Postgres to reuse free space
in old pages (see
https://www.postgresql.org/message-id/flat/CABjy%2BRhbFu_Hs8ZEiOzaPaJSGB9jqFF0gDU5gtwCLiurG3NLjQ%40mail.gmail.com
for details). I found that the HEAP_INSERT_SKIP_FSM flag accomplishes this.
For a long-term solution I see two options:

1. Introduce a reloption for this.
2. Implement it as a custom table access method in an extension.

As an experiment, I have created an extension which forwards all table
access functions to the builtin heap access method, but enables the
HEAP_INSERT_SKIP_FSM flag for heap_insert and heap_multi_insert. However,
the check in heap_getnext (
https://github.com/postgres/postgres/blob/REL_12_5/src/backend/access/heap/heapam.c#L1294-L1304)
is a showstopper. Because the custom access method uses a different
function table (so that I can override heap_insert and heap_multi_insert),
heap_getnext errors out with "only heap AM is supported". I am currently
hacking around this problem by duplicating all code up to and including
heap_getnext, with this check commented out. Clearly this is not ideal, as
changes to the heap code in future updates might cause incompatibilities.

Any ideas on how to proceed with this issue?

Thank you,
Noah Bergbauer

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2021-02-12 21:41:16 Experimenting with redo batching
Previous Message Oleg Bartunov 2021-02-12 21:00:21 Re: snowball update