Re: tablecmds: Open pg_class only when an update is required

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: tablecmds: Open pg_class only when an update is required
Date: 2025-12-11 13:17:21
Message-ID: CAExHW5tvbjm3VeyXK3F4Z_tp9i-9om_U14PaqAQjyGG=6bomdg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 11, 2025 at 12:45 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> Hi Hackers,
>
> I just noticed that relation_mark_replica_identity() unconditionally opened pg_class with RowExclusiveLock even in cases where relreplident has no change, which incurred unnecessary relation opens, lock acquisition.
>
> I just made a tiny refactor that defers opening pg_class until we know that an update to relreplident is required.

I think we need to lock the relation before fetching the tuple so that
the field being read remains consistent. Instead of upgrading the lock
which can deadlock, we get hold of row exclusive lock right at the
beginning.

--
Best Wishes,
Ashutosh Bapat

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-12-11 13:27:56 Fix and improve allocation formulas
Previous Message jian he 2025-12-11 12:56:03 regex Quantifiers {m,n}, m can be negative, n greater than 255