Re: PoC: Simplify recovery after dropping a table by LOGGING the restore LSN

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Salma Elsayed <salmasayed182003(at)gmail(dot)com>
Cc: Kirk Wolak <wolakk(at)gmail(dot)com>, zsolt(dot)parragi(at)percona(dot)com, Kirill Reshke <reshkekirill(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: PoC: Simplify recovery after dropping a table by LOGGING the restore LSN
Date: 2026-11-01 14:27:00
Message-ID: bc4f6090-3a46-4311-a3a8-30c688533545@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Salma

On 30/10/2026 16:25, Salma Elsayed wrote:
> v12 attached.

Thanks for the updated patch.

Before I jump into the test coverage, here a few more comments on the code:

== GUC name (bikeshedding) ==

The name log_object_drops is perhaps not the best fit anymore. The
feature only covers permanent tables, which is much narrower than
"object", and it also covers truncate, which is broader than "_drops". I
don't think we should spend too much time on this right now, but I
thought I should mention it for later.

== wal_level minimal ==

The lsn is being logged also when the cluster is set to wal_level =
minimal. The docs say "The minimal level generates the least WAL volume.
It logs no row information for permanent relations in transactions that
create or rewrite them." [1]

my $minimal = PostgreSQL::Test::Cluster->new('minimal');
$minimal->init;
$minimal->append_conf('postgresql.conf', 'log_object_drops = on');
$minimal->start;
$minimal->safe_psql('postgres',
'CREATE TABLE t_minimal (id int); DROP TABLE t_minimal;');
unlike(slurp_file($minimal->logfile),
$any_logged_re, 'nothing is logged with wal_level = minimal');
$minimal->stop;

== errhint in AtEOXact_DropOrTruncateTable (nit) ==

The two branches in "if (info->is_truncate) can be simplified into a
single ereport call, e.g.

ereport(LOG,
info->is_truncate ?
errmsg("table \"%s.%s\" (OID %u) truncated at LSN %X/%08X",
info->schemaname, info->relname, info->reloid,
LSN_FORMAT_ARGS(XactLastCommitStart)) :
errmsg("table \"%s.%s\" (OID %u) dropped at LSN %X/%08X",
info->schemaname, info->relname, info->reloid,
LSN_FORMAT_ARGS(XactLastCommitStart)),
info == last ?
errhint("To recover dropped or truncated tables, use "
"recovery_target_lsn = '%X/%08X' with "
"recovery_target_inclusive = false.",
LSN_FORMAT_ARGS(XactLastCommitStart)) : 0);

Best, Jim

1 -
https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-WAL-LEVEL

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-11-01 14:47:45 Re: Proposal: Conflict log history table for Logical Replication
Previous Message jian he 2026-11-01 13:55:57 Re: Use a hash table for the regexp cache