-
Notifications
You must be signed in to change notification settings - Fork 246
Fix AO storage reloptions causing spurious TOAST wraparound vacuums #1965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
+92
−0
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
||
44 changes: 44 additions & 0 deletions
src/test/regress/expected/ao_relopts_autovacuum.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
src/test/regress/sql/ao_relopts_autovacuum.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.