Document AccessExclusive lock behaviour on standbys

From: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Document AccessExclusive lock behaviour on standbys
Date: 2025-07-15 07:54:07
Message-ID: CAO6_XqqTY4hSF444P=w3cMu4x5mk0Y0-bkZz1askqj5BvY7FpQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

When a table is locked with AccessExclusive locks, the table is also
locked on standbys as the lock is propagated through the WAL and
replayed by the recovery process. This seems to surprise users as they
assume the lock is restricted to the primary and don't expect the
table to be unreadable on standbys.

I usually point to some comments in lock.c to explain this behaviour
but showing C code is not the most user friendly. There are some
mentions about this scattered in the hot-standby documentation but
users are more likely going to look at the explicit locking
documentation.

The provided patch adds more details on this in the table-level locks
documentation, making it explicit that the tables will be locked on
standbys and for how long.

Regards,
Anthonin Bonnefoy

Attachment Content-Type Size
v01-0001-Document-AccessExclusive-lock-behaviour-on-stand.patch application/octet-stream 1.5 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Sutou Kouhei 2025-07-15 07:54:13 Re: Make COPY format extendable: Extract COPY TO format implementations
Previous Message jian he 2025-07-15 07:44:10 Re: pg_dump does not dump domain not-null constraint's comments