Re: UNDO with FILEOPS, and the FLUX table AM

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Greg Burd <greg(at)burd(dot)me>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Manu <manuelreyesbravo(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Hannu Krosing <hannuk(at)google(dot)com>
Subject: Re: UNDO with FILEOPS, and the FLUX table AM
Date: 2026-10-25 22:56:42
Message-ID: CAGRkXqTKTq1cjKD+6_K1V3v8ZgAgaa4Q+jvQu+N-R-F=-5vZ_Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Greg,

Thanks for v7. It is a lot of careful work. I would really like to see UNDO
get in.

Matthias said the series does too much at once, and I agree. Maybe
it could be split into a few smaller pieces. Each one would come
with its own user.

I think crash cleanup of orphaned relation files would be a good first
user. It only needs undo at the end of recovery, so the first piece
could be much smaller than 0001. I think it only needs these parts:

- one WAL record type that adds an undo record for a transaction
- replay keeps these records in memory per xid, and drops them at
commit or abort
- checkpoint records carry the undo of open transactions
- at the end of recovery, run the undo of transactions that did not
finish, in reverse order
- a small table of undo callbacks, and pg_waldump support

It needs no undo log files and no worker. Per backend logs and FILEOPS
could wait. It does not change ROLLBACK either, which already works.

The user itself would be a new hook in RelationCreateStorage(), and it
also has to handle relfilenode reuse.

I would guess that is under 1,000 lines of C. It could be two patches.

The first is the undo core and the second is the orphaned file user.
Today 0001 to 0005 add about 18,500 lines in 110 files. Both numbers
count C code outside tests, without comments or blank lines.

I also did some research and found [1] which has more information.

In addition, I think it will be super helpful if we have a commitfeast for
that patch. CF automatically generates github links and makes patches easy
to be reviewed in a UI tool.

What do you think?

[1]
https://www.postgresql.org/message-id/9d06265c-356a-9ee7-dc22-c21a2353f986@iki.fi

Thanks,
Shihao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-10-25 23:32:29 Re: Avoid truncated or zero-padded copies of replaced files in backups.
Previous Message Manu 2026-10-25 22:05:05 Re: Assertion failure in WAL summarizer