agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix double table_close of sequence_rel in copy_sequences().
Date: Thu, 30 Apr 2026 11:11:34 +0000
Message-ID: <E1wIPIr-003S4l-1P@gemulon.postgresql.org> (raw)

Fix double table_close of sequence_rel in copy_sequences().

sequence_rel was declared at batch scope, so when a row is skipped due to
concurrent drop or insufficient privileges, the end-of-row cleanup closes
the stale pointer from the previous row, tripping the relcache refcount
assertion.

Move sequence_rel inside the per-row loop.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/CAJTYsWWOuw-yfmzotV4jCJ6LLxEsb=STLcGtDYXOxRcU9Te3Pw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2bf6c9ff71c976d0a9fb6c31d6e1da02550b5278

Modified Files
--------------
src/backend/replication/logical/sequencesync.c |  6 ++--
src/test/subscription/t/036_sequences.pl       | 39 ++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)



Message-ID: <E1wIPIr-003S4l-1P@gemulon.postgresql.org>
Permalink:  ../E1wIPIr-003S4l-1P@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wIPIr-003S4l-1P@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akapila@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix double table_close of sequence_rel in copy_sequences().
  In-Reply-To: <E1wIPIr-003S4l-1P@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox