Re: In-placre persistance change of a relation

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: hlinnaka(at)iki(dot)fi
Cc: michael(at)paquier(dot)xyz, nathandbossart(at)gmail(dot)com, postgres(at)jeltef(dot)nl, smithpb2250(at)gmail(dot)com, vignesh21(at)gmail(dot)com, jakub(dot)wartak(at)enterprisedb(dot)com, stark(dot)cfm(at)gmail(dot)com, barwick(at)gmail(dot)com, jchampion(at)timescale(dot)com, pryzby(at)telsasoft(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, rjuju123(at)gmail(dot)com, jakub(dot)wartak(at)tomtom(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, bharath(dot)rupireddyforpostgres(at)gmail(dot)com
Subject: Re: In-placre persistance change of a relation
Date: 2024-10-31 08:01:30
Message-ID: 20241031.170130.530606308716813197.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Sun, 1 Sep 2024 22:15:00 +0300, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote in
> On 31/08/2024 19:09, Kyotaro Horiguchi wrote:
> This requires fsync()ing the per-xid undo log file every time a
> relation is created. I fear that can be a pretty big performance hit
> for workloads that repeatedly create and drop small tables. Especially
> if they're otherwise running with synchronous_commit=off. Instead of
> flushing the undo log file after every write, I'd suggest WAL-logging
> the undo log like regular relations and SLRUs. So before writing the
> entry to the undo log, WAL-log it. And with a little more effort, you
> could postpone creating the files altogether until a checkpoint
> happens, similar to how twophase state files are checkpointed
> nowadays.

After some delays, here’s the new version. In this update, UNDO logs
are WAL-logged and processed in memory under most conditions. During
checkpoints, they’re flushed to files, which are then read when a
specific XID’s UNDO log is accessed for the first time during
recovery.

The biggest changes are in patches 0001 through 0004 (equivalent to
the previous 0001-0002). After that, there aren’t any major
changes. Since this update involves removing some existing features,
I’ve split these parts into multiple smaller identity transformations
to make them clearer.

As for changes beyond that, the main one is lifting the previous
restriction on PREPARE for transactions after a persistence
change. This was made possible because, with the shift to in-memory
processing of UNDO logs, commit-time crash recovery detection is now
simpler. Additional changes include completely removing the
abort-handling portion from the pendingDeletes mechanism (0008-0010).

> I'd suggest using FullTransactionId. Doesn't matter much, but seems
> like a good future-proofing.

And, the patchset now uses full transaction ids.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
v35-0001-Add-XLOG-resource-for-the-undo-log-system.patch text/x-patch 18.3 KB
v35-0002-Delay-the-reset-of-UNLOGGED-relations.patch text/x-patch 3.3 KB
v35-0003-Add-new-function-TwoPhaseXidExists.patch text/x-patch 3.4 KB
v35-0004-Introduce-undo-log-implementation.patch text/x-patch 50.2 KB
v35-0005-Remove-function-for-retaining-files-on-outer-tra.patch text/x-patch 3.8 KB
v35-0006-Remove-function-for-retaining-files-on-outer-tra.patch text/x-patch 4.4 KB
v35-0007-Prevent-orphan-storage-files-after-server-crash.patch text/x-patch 27.1 KB
v35-0008-Remove-isCommit-flag-from-PendingRelDelete.patch text/x-patch 4.0 KB
v35-0009-Remove-code-related-to-at-abort-pending-deletes.patch text/x-patch 12.4 KB
v35-0010-Rename-confusing-function-names.patch text/x-patch 7.1 KB
v35-0011-new-indexam-bit-for-unlogged-storage-compatibili.patch text/x-patch 5.1 KB
v35-0012-Transactional-buffer-persistence-switching.patch text/x-patch 20.9 KB
v35-0013-Prepare-for-preventing-DML-operations-on-relatio.patch text/x-patch 11.3 KB
v35-0014-Add-a-new-version-of-copy_file-to-allow-overwrit.patch text/x-patch 2.4 KB
v35-0015-In-place-persistance-change-to-UNLOGGED.patch text/x-patch 11.4 KB
v35-0016-Add-test-for-ALTER-TABLE-UNLOGGED.patch text/x-patch 15.5 KB
v35-0017-Make-smgrdounlinkall-accept-fork-numbers.patch text/x-patch 13.2 KB
v35-0018-Enable-commit-records-to-handle-fork-removals.patch text/x-patch 13.8 KB
v35-0019-Add-per-fork-deletion-support-to-pendingDeletes.patch text/x-patch 7.7 KB
v35-0020-Allow-init-fork-to-be-dropped.patch text/x-patch 3.7 KB
v35-0021-In-place-persistence-change-to-LOGGED.patch text/x-patch 5.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Soumyadeep Chakraborty 2024-10-31 08:03:06 Re: InstallXLogFileSegment() vs concurrent WAL flush
Previous Message Vladlen Popolitov 2024-10-31 06:37:31 Re: [PATCH] Add array_reverse() function