Re: In-placre persistance change of a relation

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: michael(at)paquier(dot)xyz
Cc: 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, hlinnaka(at)iki(dot)fi, 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-08-31 16:09:25
Message-ID: 20240901.010925.656452225144636594.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

It's been a while. Based on our previous face-to-face discussions, I
have been restructuring the patch set. During this process, I found
several missing parts and issues, which led to almost everything being
rewritten. However, I believe the updates are now better organized and
more understandable.

The current patch set broadly consists of the following elements:

- Core feature: Switching buffer persistence (0007) remains mostly the
same as before, but the creation and deletion of INIT fork files
have undergone significant modifications. Part of this functionality
has been moved to commit records.

- UNDO log(0002): This handles file deletion during transaction aborts,
which was previously managed, in part, by the commit XLOG record at
the end of a transaction.

- Prevent orphan files after a crash (0005): This is another use-case
of the UNDO log system.

- Extension of smgr (0012), pendingDeletes (0014), and commit XLOG
records (0013): These have been extended to handle file deletion at
the fork level instead of the relfilenumber level. While this
extension applies to both commit and abort operations, only the file
deletion process for aborts has been moved to the UNDO log. As a
result, file deletions during commits continue to be managed by
commit records.

Here are some issues. Depending on how these points are addressed,
this patch set might be dropped. (Or, this patch might already be too
large for its intended effect.)

- Consecutive changes to the persistence of the same table within a
single transaction are prohibited (0007). Allowing this would
complicate pendingDeletes and a similar mechanism added to
bufmgr. Also, due to the append-only nature of the UNDO log, the
entire process, including subtransaction handling, could not be made
consistent easily.

- PREPARE is prohibited for transactions that have altered table
persistence(0009). This is because I haven't found a simple way to
ensure consistent switching of buffer persistence if the server
crashes after PREPARE and then commits the transaction after
recovery.

- Data updates within a single transaction after changing the table's
persistence are also prohibited(0008). This restriction is necessary
because if an index update triggers page splits after changing the
persistence to UNLOGGED, WAL might become inapplicable.

The last point, in particular, has a significant impact on usability,
but it seems to be fundamentally unavoidable. Since heap updates
appear to be fine, one possible approach could be to give up on
in-place persistence changes for indexes.

Regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
v34-0001-Export-wal_sync_method-related-functions.patch text/x-patch 3.9 KB
v34-0002-Introduce-undo-log-implementation.patch text/x-patch 44.5 KB
v34-0003-Remove-function-for-retaining-files-on-outer-tra.patch text/x-patch 3.9 KB
v34-0004-Remove-function-for-retaining-files-on-outer-tra.patch text/x-patch 4.4 KB
v34-0005-Prevent-orphan-storage-files-after-server-crash.patch text/x-patch 23.2 KB
v34-0006-new-indexam-bit-for-unlogged-storage-compatibili.patch text/x-patch 5.1 KB
v34-0007-Transactional-buffer-persistence-switching.patch text/x-patch 20.2 KB
v34-0008-Prepare-for-preventing-DML-operations-on-relatio.patch text/x-patch 11.1 KB
v34-0009-Prevent-PREPARE-for-transactions-with-in-place-r.patch text/x-patch 2.6 KB
v34-0010-In-place-persistance-change-to-UNLOGGED.patch text/x-patch 8.8 KB
v34-0011-Add-test-for-ALTER-TABLE-UNLOGGED.patch text/x-patch 15.6 KB
v34-0012-Make-smgrdounlinkall-accept-forknumbers.patch text/x-patch 12.7 KB
v34-0013-Enable-commit-records-to-handle-fork-removals.patch text/x-patch 20.6 KB
v34-0014-Add-per-fork-deletion-support-to-pendingDeletes.patch text/x-patch 7.7 KB
v34-0015-Allow-init-fork-to-be-dropped.patch text/x-patch 4.3 KB
v34-0016-In-place-persistence-change-to-LOGGED.patch text/x-patch 5.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-08-31 16:59:02 Re: Add tests for PL/pgSQL SRFs
Previous Message Junwang Zhao 2024-08-31 12:30:34 Re: generic plans and "initial" pruning