pgsql: Fix double table_close of sequence_rel in copy_sequences().

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix double table_close of sequence_rel in copy_sequences().
Date: 2026-04-30 11:11:34
Message-ID: E1wIPIr-003S4l-1P@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)slg01(at)gmail(dot)com>
Reviewed-by: vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-04-30 11:46:34 pgsql: Improve handling of concurrent checksum requests
Previous Message Michael Paquier 2026-04-30 09:45:10 pgsql: Fix errno check based on EINTR in pg_flush_data()