pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY)
3+ messages / 1 participants
[nested] [flat]

* pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY)
@ 2026-09-28 15:13 Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Álvaro Herrera @ 2026-09-28 15:13 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock the TOAST table early in REPACK (CONCURRENTLY)

The decoding worker records the relfilenumber of the TOAST table when it
starts, and skips changes stored under any other one, but the TOAST
table was not locked until the data copy began.  If VACUUM FULL rewrote
it while the worker was starting, concurrent updates of TOASTed columns
were silently lost.

Fix by locking the TOAST table in cluster_rel() in the concurrent case,
before the worker starts.

Author: Shihao Zhong <zhong950419@gmail.com>
Reported-by: Thom Brown <thom@linux.com>
Backpatch-through: 19
Discussion: https://postgr.es/m/CAA-aLv5MF6BLL+BWvix2Yw+CBardtH43AofPReQunhDZPNBtuA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1813f951cad59ea7f86063831d0222c429989c91

Modified Files
--------------
src/backend/commands/repack.c                      |  34 ++++-
src/backend/commands/repack_worker.c               |   5 +-
.../injection_points/expected/repack_toast.out     | 152 ++++++++++++++++++++-
.../injection_points/specs/repack_toast.spec       |  45 ++++++
4 files changed, 229 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY)
@ 2026-09-28 15:13 Álvaro Herrera <alvherre@kurilemu.de>
  2026-09-28 15:23 ` Re: pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY) Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Álvaro Herrera @ 2026-09-28 15:13 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock the TOAST table early in REPACK (CONCURRENTLY)

The decoding worker records the relfilenumber of the TOAST table when it
starts, and skips changes stored under any other one, but the TOAST
table was not locked until the data copy began.  If VACUUM FULL rewrote
it while the worker was starting, concurrent updates of TOASTed columns
were silently lost.

Fix by locking the TOAST table in cluster_rel() in the concurrent case,
before the worker starts.

Author: Shihao Zhong <zhong950419@gmail.com>
Reported-by: Thom Brown <thom@linux.com>
Backpatch-through: 19
Discussion: https://postgr.es/m/CAA-aLv5MF6BLL+BWvix2Yw+CBardtH43AofPReQunhDZPNBtuA@mail.gmail.com

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/76a268273c87b8efda86a3a729f5b89c60f48882

Modified Files
--------------
src/backend/commands/repack.c                      |  34 ++++-
src/backend/commands/repack_worker.c               |   5 +-
.../injection_points/expected/repack_toast.out     | 152 ++++++++++++++++++++-
.../injection_points/specs/repack_toast.spec       |  45 ++++++
4 files changed, 229 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY)
  2026-09-28 15:13 pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY) Álvaro Herrera <alvherre@kurilemu.de>
@ 2026-09-28 15:23 ` Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Álvaro Herrera @ 2026-09-28 15:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

On 2026-Sep-28, Álvaro Herrera wrote:

> Lock the TOAST table early in REPACK (CONCURRENTLY)
> 
> The decoding worker records the relfilenumber of the TOAST table when it
> starts, and skips changes stored under any other one, but the TOAST
> table was not locked until the data copy began.  If VACUUM FULL rewrote
> it while the worker was starting, concurrent updates of TOASTed columns
> were silently lost.

Oops, I used CheckRelationOidLockedByMe() assuming it does what its name
implies, which it doesn't.  Will fix.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"After a quick R of TFM, all I can say is HOLY CR** THAT IS COOL! PostgreSQL was
amazing when I first started using it at 7.2, and I'm continually astounded by
learning new features and techniques made available by the continuing work of
the development team."
Berend Tober, http://archives.postgresql.org/pgsql-hackers/2007-08/msg01009.php






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-09-28 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 15:13 pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY) Álvaro Herrera <alvherre@kurilemu.de>
2026-09-28 15:13 pgsql: Lock the TOAST table early in REPACK (CONCURRENTLY) Álvaro Herrera <alvherre@kurilemu.de>
2026-09-28 15:23 ` Álvaro Herrera <alvherre@kurilemu.de>

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