diff options
| author | Masahiko Sawada <msawada@postgresql.org> | 2025-03-18 16:36:59 -0700 | 
|---|---|---|
| committer | Masahiko Sawada <msawada@postgresql.org> | 2025-03-18 16:36:59 -0700 | 
| commit | a38dce3c4a90aa0facef350bc6a502f31b0cfa31 (patch) | |
| tree | 3da04cf108c6cf82067e2d3dc462eaae876e5c2d /src/test | |
| parent | ee578921b60ef9a14eaea54b608549e4f8b14f26 (diff) | |
Fix assertion failure in parallel vacuum with minimal maintenance_work_mem setting.
bbf668d66fbf lowered the minimum value of maintenance_work_mem to
64kB. However, in parallel vacuum cases, since the initial underlying
DSA size is 256kB, it attempts to perform a cycle of index vacuuming
and table vacuuming with an empty TID store, resulting in an assertion
failure.
This commit ensures that at least one page is processed before index
vacuuming and table vacuuming begins.
Backpatch to 17, where the minimum maintenance_work_mem value was
lowered.
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAD21AoCEAmbkkXSKbj4dB+5pJDRL4ZHxrCiLBgES_g_g8mVi1Q@mail.gmail.com
Backpatch-through: 17
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/vacuum.out | 12 | ||||
| -rw-r--r-- | src/test/regress/sql/vacuum.sql | 13 | 
2 files changed, 25 insertions, 0 deletions
| diff --git a/src/test/regress/expected/vacuum.out b/src/test/regress/expected/vacuum.out index 2eba7128876..7518806e61f 100644 --- a/src/test/regress/expected/vacuum.out +++ b/src/test/regress/expected/vacuum.out @@ -148,6 +148,10 @@ CREATE INDEX brin_pvactst ON pvactst USING brin (i);  CREATE INDEX gin_pvactst ON pvactst USING gin (a);  CREATE INDEX gist_pvactst ON pvactst USING gist (p);  CREATE INDEX spgist_pvactst ON pvactst USING spgist (p); +CREATE TABLE pvactst2 (i INT) WITH (autovacuum_enabled = off); +INSERT INTO pvactst2 SELECT generate_series(1, 1000); +CREATE INDEX ON pvactst2 (i); +CREATE INDEX ON pvactst2 (i);  -- VACUUM invokes parallel index cleanup  SET min_parallel_index_scan_size to 0;  VACUUM (PARALLEL 2) pvactst; @@ -167,6 +171,13 @@ VACUUM (PARALLEL) pvactst; -- error, cannot use PARALLEL option without parallel  ERROR:  parallel option requires a value between 0 and 1024  LINE 1: VACUUM (PARALLEL) pvactst;                  ^ +-- Test parallel vacuum using the minimum maintenance_work_mem with and without +-- dead tuples. +SET maintenance_work_mem TO 64; +VACUUM (PARALLEL 2) pvactst2; +DELETE FROM pvactst2 WHERE i < 1000; +VACUUM (PARALLEL 2) pvactst2; +RESET maintenance_work_mem;  -- Test different combinations of parallel and full options for temporary tables  CREATE TEMPORARY TABLE tmp (a int PRIMARY KEY);  CREATE INDEX tmp_idx1 ON tmp (a); @@ -175,6 +186,7 @@ WARNING:  disabling parallel option of vacuum on "tmp" --- cannot vacuum tempora  VACUUM (PARALLEL 0, FULL TRUE) tmp; -- can specify parallel disabled (even though that's implied by FULL)  RESET min_parallel_index_scan_size;  DROP TABLE pvactst; +DROP TABLE pvactst2;  -- INDEX_CLEANUP option  CREATE TABLE no_index_cleanup (i INT PRIMARY KEY, t TEXT);  -- Use uncompressed data stored in toast. diff --git a/src/test/regress/sql/vacuum.sql b/src/test/regress/sql/vacuum.sql index 548cd7accac..d272dd064eb 100644 --- a/src/test/regress/sql/vacuum.sql +++ b/src/test/regress/sql/vacuum.sql @@ -113,6 +113,10 @@ CREATE INDEX brin_pvactst ON pvactst USING brin (i);  CREATE INDEX gin_pvactst ON pvactst USING gin (a);  CREATE INDEX gist_pvactst ON pvactst USING gist (p);  CREATE INDEX spgist_pvactst ON pvactst USING spgist (p); +CREATE TABLE pvactst2 (i INT) WITH (autovacuum_enabled = off); +INSERT INTO pvactst2 SELECT generate_series(1, 1000); +CREATE INDEX ON pvactst2 (i); +CREATE INDEX ON pvactst2 (i);  -- VACUUM invokes parallel index cleanup  SET min_parallel_index_scan_size to 0; @@ -130,6 +134,14 @@ VACUUM (PARALLEL 2, INDEX_CLEANUP FALSE) pvactst;  VACUUM (PARALLEL 2, FULL TRUE) pvactst; -- error, cannot use both PARALLEL and FULL  VACUUM (PARALLEL) pvactst; -- error, cannot use PARALLEL option without parallel degree +-- Test parallel vacuum using the minimum maintenance_work_mem with and without +-- dead tuples. +SET maintenance_work_mem TO 64; +VACUUM (PARALLEL 2) pvactst2; +DELETE FROM pvactst2 WHERE i < 1000; +VACUUM (PARALLEL 2) pvactst2; +RESET maintenance_work_mem; +  -- Test different combinations of parallel and full options for temporary tables  CREATE TEMPORARY TABLE tmp (a int PRIMARY KEY);  CREATE INDEX tmp_idx1 ON tmp (a); @@ -137,6 +149,7 @@ VACUUM (PARALLEL 1, FULL FALSE) tmp; -- parallel vacuum disabled for temp tables  VACUUM (PARALLEL 0, FULL TRUE) tmp; -- can specify parallel disabled (even though that's implied by FULL)  RESET min_parallel_index_scan_size;  DROP TABLE pvactst; +DROP TABLE pvactst2;  -- INDEX_CLEANUP option  CREATE TABLE no_index_cleanup (i INT PRIMARY KEY, t TEXT); | 
