Re: [PATCH] Fix NULL dereference in subscription REFRESH on concurrent DROP

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Ajin Cherian <itsajin(at)gmail(dot)com>
Cc: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Fix NULL dereference in subscription REFRESH on concurrent DROP
Date: 2026-07-31 01:15:00
Message-ID: CALj2ACXp9u54KEy0e74fFtGM8_3Jmbs5_MHdtnYTrScNo2f0Zg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sun, May 31, 2026 at 11:30 PM Ajin Cherian <itsajin(at)gmail(dot)com> wrote:
>
> I've reviewed the patch and it looks good

Thanks Satya for the off-list discussion, and thanks Ajin for the review.

> just a small comment - instead of silently continuing after finding a dropped local table, would you want to log an error message?

IMHO, logging a message is unnecessary. The origin check only raises a
WARNING and doesn't drive the actual refresh, so silently skipping a
concurrently dropped relation is harmless.

A similar fix for concurrent relation drops in
pg_get_publication_tables() is in commit 63e7a0d2c, and I'm following
it in using try_table_open() and in not logging for dropped local
relations.

Please find attached the v2 patch. It has the following changes:

1/ Uses try_table_open() for all relations and gets the namespace
using RelationGetNamespace().
2/ Deduplicates the common code that quotes the subscription
relations' schema-qualified names for tables and sequences into a
helper function.
3/ Adds a TAP test with an injection point in 0002 (which I don't
intend to be committed).

We may need to backpatch the tables and sequences fix down to PG19,
and just the tables fix down to PG16 (commit 8756930190).

Thoughts?

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v2-0001-Fix-crash-in-subscription-REFRESH-on-concurrent-r.patch application/x-patch 5.7 KB
v2-0002-Test-subscription-REFRESH-with-concurrently-dropp.patch application/x-patch 5.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Xuneng Zhou 2026-07-31 01:46:46 Re: Implement waiting for wal lsn replay: reloaded
Previous Message Xuneng Zhou 2026-07-31 00:58:53 Re: Implement waiting for wal lsn replay: reloaded