Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/backend/postmaster/autovacuum.c
Original file line number Diff line number Diff line change
Expand Up @@ -2957,6 +2957,16 @@ extract_autovac_opts(HeapTuple tup, TupleDesc pg_class_desc)
relam != AO_COLUMN_TABLE_AM_OID)
return NULL;

/*
* AO reloptions use RELOPT_KIND_APPENDOPTIMIZED which does not include
* autovacuum reloptions, so the embedded AutoVacOpts is zero-filled.
* Returning it would make TOAST inherit freeze_max_age=0, triggering
* spurious aggressive wraparound vacuums. AO auxiliary and TOAST
* relations use the heap AM, so they are unaffected by this guard.
*/
if (IsAccessMethodAO(relam))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can handle the IsAccessMethodAO(relam) case in the existing if condition line 2955, so the additional check is unnecessary.

return NULL;

relopts = extractRelOptions(tup, pg_class_desc, tam->amoptions);
if (relopts == NULL)
return NULL;
Expand Down
44 changes: 44 additions & 0 deletions src/test/regress/expected/ao_relopts_autovacuum.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- AO storage reloptions must not produce zeroed autovacuum options
-- that get inherited by the TOAST relation.
CREATE SCHEMA ao_relopts_av_test;
SET search_path = ao_relopts_av_test;
CREATE TABLE ao_row_with_storage_opts
(
id integer,
payload text
)
WITH
(
appendonly=true,
orientation=row,
compresstype=zlib,
compresslevel=1,
checksum=true
)
DISTRIBUTED RANDOMLY;
INSERT INTO ao_row_with_storage_opts VALUES (1, repeat('x', 10000));
-- Parent has only storage reloptions.
SELECT option_name, option_value
FROM pg_options_to_table(
(SELECT reloptions FROM pg_class
WHERE oid = 'ao_row_with_storage_opts'::regclass))
ORDER BY option_name;
option_name | option_value
---------------+--------------
checksum | true
compresslevel | 1
compresstype | zlib
(3 rows)

-- TOAST has no reloptions of its own.
SELECT t.reloptions IS NULL AS toast_no_reloptions
FROM pg_class c
JOIN pg_class t ON t.oid = c.reltoastrelid
WHERE c.oid = 'ao_row_with_storage_opts'::regclass;
toast_no_reloptions
---------------------
t
(1 row)

DROP SCHEMA ao_relopts_av_test CASCADE;
NOTICE: drop cascades to table ao_row_with_storage_opts
1 change: 1 addition & 0 deletions src/test/regress/greenplum_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
test: autovacuum
test: autovacuum-segment
test: autovacuum-template0-segment
test: ao_relopts_autovacuum

# check profile feature
test: profile
Expand Down
37 changes: 37 additions & 0 deletions src/test/regress/sql/ao_relopts_autovacuum.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- AO storage reloptions must not produce zeroed autovacuum options
-- that get inherited by the TOAST relation.

CREATE SCHEMA ao_relopts_av_test;
SET search_path = ao_relopts_av_test;

CREATE TABLE ao_row_with_storage_opts
(
id integer,
payload text
)
WITH
(
appendonly=true,
orientation=row,
compresstype=zlib,
compresslevel=1,
checksum=true
)
DISTRIBUTED RANDOMLY;

INSERT INTO ao_row_with_storage_opts VALUES (1, repeat('x', 10000));

-- Parent has only storage reloptions.
SELECT option_name, option_value
FROM pg_options_to_table(
(SELECT reloptions FROM pg_class
WHERE oid = 'ao_row_with_storage_opts'::regclass))
ORDER BY option_name;

-- TOAST has no reloptions of its own.
SELECT t.reloptions IS NULL AS toast_no_reloptions
FROM pg_class c
JOIN pg_class t ON t.oid = c.reltoastrelid
WHERE c.oid = 'ao_row_with_storage_opts'::regclass;

DROP SCHEMA ao_relopts_av_test CASCADE;
Loading