Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4290f2

Browse files
Fix assertion failure in parallel vacuum with minimal maintenance_work_mem setting.
bbf668d lowered the minimum value of maintenance_work_mem to64kB. However, in parallel vacuum cases, since the initial underlyingDSA size is 256kB, it attempts to perform a cycle of index vacuumingand table vacuuming with an empty TID store, resulting in an assertionfailure.This commit ensures that at least one page is processed before indexvacuuming and table vacuuming begins.Backpatch to 17, where the minimum maintenance_work_mem value waslowered.Reviewed-by: David Rowley <dgrowleyml@gmail.com>Discussion:https://postgr.es/m/CAD21AoCEAmbkkXSKbj4dB+5pJDRL4ZHxrCiLBgES_g_g8mVi1Q@mail.gmail.comBackpatch-through: 17
1 parent6d3ea48 commitf4290f2

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,9 +1263,12 @@ lazy_scan_heap(LVRelState *vacrel)
12631263
* Consider if we definitely have enough space to process TIDs on page
12641264
* already. If we are close to overrunning the available space for
12651265
* dead_items TIDs, pause and do a cycle of vacuuming before we tackle
1266-
* this page.
1266+
* this page. However, let's force at least one page-worth of tuples
1267+
* to be stored as to ensure we do at least some work when the memory
1268+
* configured is so low that we run out before storing anything.
12671269
*/
1268-
if (TidStoreMemoryUsage(vacrel->dead_items)>vacrel->dead_items_info->max_bytes)
1270+
if (vacrel->dead_items_info->num_items>0&&
1271+
TidStoreMemoryUsage(vacrel->dead_items)>vacrel->dead_items_info->max_bytes)
12691272
{
12701273
/*
12711274
* Before beginning index vacuuming, we release any pin we may

‎src/test/regress/expected/vacuum.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ CREATE INDEX brin_pvactst ON pvactst USING brin (i);
148148
CREATE INDEX gin_pvactst ON pvactst USING gin (a);
149149
CREATE INDEX gist_pvactst ON pvactst USING gist (p);
150150
CREATE INDEX spgist_pvactst ON pvactst USING spgist (p);
151+
CREATE TABLE pvactst2 (i INT) WITH (autovacuum_enabled = off);
152+
INSERT INTO pvactst2 SELECT generate_series(1, 1000);
153+
CREATE INDEX ON pvactst2 (i);
154+
CREATE INDEX ON pvactst2 (i);
151155
-- VACUUM invokes parallel index cleanup
152156
SET min_parallel_index_scan_size to 0;
153157
VACUUM (PARALLEL 2) pvactst;
@@ -167,6 +171,13 @@ VACUUM (PARALLEL) pvactst; -- error, cannot use PARALLEL option without parallel
167171
ERROR: parallel option requires a value between 0 and 1024
168172
LINE 1: VACUUM (PARALLEL) pvactst;
169173
^
174+
-- Test parallel vacuum using the minimum maintenance_work_mem with and without
175+
-- dead tuples.
176+
SET maintenance_work_mem TO 64;
177+
VACUUM (PARALLEL 2) pvactst2;
178+
DELETE FROM pvactst2 WHERE i < 1000;
179+
VACUUM (PARALLEL 2) pvactst2;
180+
RESET maintenance_work_mem;
170181
-- Test different combinations of parallel and full options for temporary tables
171182
CREATE TEMPORARY TABLE tmp (a int PRIMARY KEY);
172183
CREATE INDEX tmp_idx1 ON tmp (a);
@@ -175,6 +186,7 @@ WARNING: disabling parallel option of vacuum on "tmp" --- cannot vacuum tempora
175186
VACUUM (PARALLEL 0, FULL TRUE) tmp; -- can specify parallel disabled (even though that's implied by FULL)
176187
RESET min_parallel_index_scan_size;
177188
DROP TABLE pvactst;
189+
DROP TABLE pvactst2;
178190
-- INDEX_CLEANUP option
179191
CREATE TABLE no_index_cleanup (i INT PRIMARY KEY, t TEXT);
180192
-- Use uncompressed data stored in toast.

‎src/test/regress/sql/vacuum.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ CREATE INDEX brin_pvactst ON pvactst USING brin (i);
113113
CREATEINDEXgin_pvactstON pvactst USING gin (a);
114114
CREATEINDEXgist_pvactstON pvactst USING gist (p);
115115
CREATEINDEXspgist_pvactstON pvactst USING spgist (p);
116+
CREATETABLEpvactst2 (iINT) WITH (autovacuum_enabled= off);
117+
INSERT INTO pvactst2SELECT generate_series(1,1000);
118+
CREATEINDEXON pvactst2 (i);
119+
CREATEINDEXON pvactst2 (i);
116120

117121
-- VACUUM invokes parallel index cleanup
118122
SET min_parallel_index_scan_size to0;
@@ -130,13 +134,22 @@ VACUUM (PARALLEL 2, INDEX_CLEANUP FALSE) pvactst;
130134
VACUUM (PARALLEL2, FULL TRUE) pvactst;-- error, cannot use both PARALLEL and FULL
131135
VACUUM (PARALLEL) pvactst;-- error, cannot use PARALLEL option without parallel degree
132136

137+
-- Test parallel vacuum using the minimum maintenance_work_mem with and without
138+
-- dead tuples.
139+
SET maintenance_work_mem TO64;
140+
VACUUM (PARALLEL2) pvactst2;
141+
DELETEFROM pvactst2WHERE i<1000;
142+
VACUUM (PARALLEL2) pvactst2;
143+
RESET maintenance_work_mem;
144+
133145
-- Test different combinations of parallel and full options for temporary tables
134146
CREATE TEMPORARY TABLE tmp (aintPRIMARY KEY);
135147
CREATEINDEXtmp_idx1ON tmp (a);
136148
VACUUM (PARALLEL1, FULL FALSE) tmp;-- parallel vacuum disabled for temp tables
137149
VACUUM (PARALLEL0, FULL TRUE) tmp;-- can specify parallel disabled (even though that's implied by FULL)
138150
RESET min_parallel_index_scan_size;
139151
DROPTABLE pvactst;
152+
DROPTABLE pvactst2;
140153

141154
-- INDEX_CLEANUP option
142155
CREATETABLEno_index_cleanup (iINTPRIMARY KEY, tTEXT);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp