RE: Temporary slot leak when creation fails in a subtransaction

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Bharath Rupireddy' <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: RE: Temporary slot leak when creation fails in a subtransaction
Date: 2026-09-28 10:37:57
Message-ID: OS7PR01MB18317225F75ADD4904EA2C1C3F58D2@OS7PR01MB18317.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Bharath,

> Here is a reproducer for a temporary logical slot [2]. The slot is
> left with restart_lsn and catalog_xmin set and confirmed_flush_lsn not
> set. A slot in that state can still be used for decoding, and with no
> confirmed_flush_lsn that can lose data (see the test case in the
> attached patch). There is no start point, and since decoding from the
> slot is not slot creation, the snapshot builder can restore a
> serialized snapshot and become consistent in the middle of a
> transaction that began before restart_lsn. Without the fix, the
> healthy slot in the test returns the transaction with both inserts and
> the leftover slot returns it with only the second one.

Confirmed that the temp slot could retain even after applying the premise patch.

> A few ways to fix this were discussed in the other thread.

FYI, I considered an alternative: register to resource owner. My idea was to
register the replication slot while creating the slot, and release or drop it based
on the needs, but it seems just introducing complexity. Also releasing callback
must not perform operations could fail like memory allocation, so it's not appropriate.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message ZizhuanLiu X-MAN 2026-09-28 10:45:40 Re: Optimize MCV stats for sortable types and utilize sorted-order properties
Previous Message shveta malik 2026-09-28 10:33:01 Re: Persist slot invalidations before publishing them