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 El-Sayed <salmasayed182003(at)gmail(dot)com>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Kirk Wolak <wolakk(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-10-12 16:45:13
Message-ID: 9cee6ffe-05b0-4ca9-a1fc-3b1d421c3c04@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Salma

On 12/10/2026 14:14, Salma El-Sayed wrote:
> Attached is v8 rebased on master.

Thanks for the update.

I played a bit with v8 and it seems that the lsn is logged a bit too
early. If a drop database command fails, it still gets logged:

psql (20devel)
Type "help" for help.

postgres=# create table t (g int, pad text);
CREATE TABLE
postgres=# insert into t select g, repeat('x', 100) from
generate_series(1, 600000) g;
INSERT 0 600000
postgres=# create database db;
CREATE DATABASE
postgres=# update t set g = g + 1;
UPDATE 600000
postgres=# set log_object_drops to on;
SET
postgres=# set statement_timeout = '20ms';
SET
postgres=# drop database db;
ERROR: canceling statement due to statement timeout

postgres=# select oid,datname from pg_database where datname = 'db';
oid | datname
-------+---------
16414 | db
(1 row)

.. but the logs show:

LOG: database "db" (OID 16414) dropped, lsn=0/47AAC7E0

Just for testing, I placed the ereport after remove_dbtablespaces() and
the lsn is no longer logged in the scenario above -- see 0002, but it
needs more testing. WDYT?

I will take a closer look at the tests in the next few days.

Best, Jim

Attachment Content-Type Size
v9-0001-Add-LSN-logging-for-DROP-TRUNCATE-TABLE-and-DROP-.patch text/x-patch 51.2 KB
v9-0002-fix-premature-lsn-logging.patch text/x-patch 1.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message alvherre@kurilemu.de 2026-10-12 17:15:45 Re: Bug in logical decoding with DDL and subtransactions
Previous Message Nisha Moond 2026-10-12 16:04:11 Re: Proposal: Conflict log history table for Logical Replication