From 265e9f5549297b8436c84f25cba6dc62b4372561 Mon Sep 17 00:00:00 2001 From: Dave Sharpe Date: Tue, 24 Nov 2026 12:36:51 +0000 Subject: [PATCH v1 1/3] doc: REPACK (CONCURRENTLY) affects snapshots taken before it commits The warning in the REPACK reference page says the table appears empty to transactions "using a snapshot taken before repacking started". The affected snapshots are those taken before the repacking transaction committed, which is what the "Caveats" section of the MVCC chapter says for the same command. A snapshot taken while REPACK (CONCURRENTLY) runs reads the table as empty too: for example, a pg_dump started during the repack, which takes its snapshot before it locks the table. Also say how to disable the option for a whole server: max_repack_replication_slots = 0 makes REPACK (CONCURRENTLY) fail with "REPACK can only be used if "max_repack_replication_slots" > 0", while REPACK without CONCURRENTLY, which needs no slot, still runs. Reproducer (REL_19_0), two sessions: CREATE TABLE t (id int PRIMARY KEY); INSERT INTO t SELECT generate_series(1, 5); CREATE TABLE other (id int); s1: REPACK (CONCURRENTLY) t; -- still running, e.g. waiting for -- a transaction that locked t s2: BEGIN ISOLATION LEVEL REPEATABLE READ; s2: SELECT count(*) FROM other; -- snapshot taken after REPACK started s1: (REPACK commits) s2: SELECT count(*) FROM t; -- 0, expected 5 Backpatch-through: 19 Co-Authored-By: Claude Opus 5.5 --- doc/src/sgml/config.sgml | 2 ++ doc/src/sgml/ref/repack.sgml | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 28440932a73..b611057e78c 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -4832,6 +4832,8 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows Specifies the maximum number of replication slots for use of the REPACK command. The default is 5. + With a value of zero, REPACK cannot be used + with the CONCURRENTLY option. This parameter can only be set at server start. diff --git a/doc/src/sgml/ref/repack.sgml b/doc/src/sgml/ref/repack.sgml index 0649e033aa1..194d65efc88 100644 --- a/doc/src/sgml/ref/repack.sgml +++ b/doc/src/sgml/ref/repack.sgml @@ -334,9 +334,17 @@ REPACK [ ( option [, ...] ) ] USING REPACK with the CONCURRENTLY option is not MVCC-safe. After the repacking transaction commits, the table will appear empty to concurrent transactions, if they are - using a snapshot taken before repacking started. + using a snapshot taken before the repacking transaction committed. + That includes a snapshot taken while REPACK was + running. See for more details. + + To prevent the use of the CONCURRENTLY option on a + server, set to + zero. REPACK without + CONCURRENTLY remains available. + base-commit: 9ebc9a458c38465cd9609814cfc9ca3a2f46fef5 -- 2.43.0