[PATCH] Add recovery boundary WAL record for database and tablespace commands

From: JoongHyuk Shin <sjh910805(at)gmail(dot)com>
To: pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [PATCH] Add recovery boundary WAL record for database and tablespace commands
Date: 2026-09-07 05:21:21
Message-ID: CACSdjfPmjJO1=Lo9qbCmyc9SBKmJQ4YV_mFbCPkXZf7g5+Qdeg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

CREATE/DROP DATABASE, ALTER DATABASE SET TABLESPACE
and CREATE/DROP TABLESPACE change directories as their WAL is replayed,
while recovery_target_time is only checked on commit and abort records.
So a target set before such a command does not stop recovery before it,
leaving a dropped database gone or an orphan directory.
This was reported in [1] and again in [2].

0001 emits an XLOG2 record carrying a timestamp
before the first irreversible record of each command
and stops recovery before it when the timestamp is past the target.
Stopping there loses nothing, as replaying the record has no effect.

0002 makes recovery_min_apply_delay wait on the record too.
A delayed standby currently removes a dropped database's directory
as soon as it reads the drop, long before the delay expires.

[1]
https://www.postgresql.org/message-id/flat/aac5c3e6-2805-ba06-143b-070478aa9434(at)loxodata(dot)com
[2]
https://www.postgresql.org/message-id/flat/43f0c3df-a23c-4159-9610-934d3dceb80c(at)pgbackrest(dot)org

--
JH Shin

Attachment Content-Type Size
0002-Make-recovery_min_apply_delay-wait-on-recovery-bound.patch application/octet-stream 5.2 KB
0001-Add-recovery-boundary-WAL-record-for-database-and-ta.patch application/octet-stream 15.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Osama Abdul Qader 2026-09-07 05:31:07 Re: Fix detection of truncated zstd-compressed backups
Previous Message Zhijie Hou (Fujitsu) 2026-09-07 05:17:09 RE: Remove stale XXX comment in logical launcher