Preventing free space from being reused - Mailing list pgsql-hackers

From Noah Bergbauer
Subject Preventing free space from being reused
Date
Msg-id CABjy+RgC_GHW2jvpjZseq80y0KP=JXX6rV1JtpFk9M39G+_mDQ@mail.gmail.com
Whole thread Raw
Responses Re: Preventing free space from being reused
List 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

pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: snowball update
Next
From: Thomas Munro
Date:
Subject: Experimenting with redo batching