This is an automated email from the ASF dual-hosted git repository. yjhjstz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit cf51441ba32d218d24b417c503da5b959c9189da Author: linxu.hlx <[email protected]> AuthorDate: Wed May 8 11:44:32 2024 +0800 Fix crash caused by vacuum ao_aux_only on AO partitioned table. Appendonly partitioned table do not have any auxiliary table, so partitioned table itself should not participate in VACUUM AO_AUX_ONLY Reviewed-by: Huansong Fu <[email protected]> --- src/backend/commands/vacuum.c | 7 +++++++ src/test/regress/expected/vacuum_ao_aux_only.out | 8 ++++++++ src/test/regress/sql/vacuum_ao_aux_only.sql | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index c1af63c420..5c3f7249e5 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -1138,6 +1138,13 @@ expand_vacuum_rel(VacuumRelation *vrel, int options) classForm = (Form_pg_class) GETSTRUCT(tuple); if (IsAccessMethodAO(classForm->relam)) { + /* no aux tables for a parent AO table */ + if (classForm->relkind == RELKIND_PARTITIONED_TABLE) + { + ReleaseSysCache(tuple); + continue; + } + Relation aorel = table_open(classForm->oid, AccessShareLock); oldcontext = MemoryContextSwitchTo(vac_context); diff --git a/src/test/regress/expected/vacuum_ao_aux_only.out b/src/test/regress/expected/vacuum_ao_aux_only.out index 41e13c3b4f..4ab200419c 100644 --- a/src/test/regress/expected/vacuum_ao_aux_only.out +++ b/src/test/regress/expected/vacuum_ao_aux_only.out @@ -149,6 +149,14 @@ FROM gp_segment_configuration WHERE role = 'p' AND content != -1; Success: (3 rows) +-- test against mixed partitioned appendonly table +CREATE TABLE vac_example_ao(i int, j int) with (appendonly=true, orientation=column) PARTITION BY range (j) +( + start (1) end (3) with (appendonly=false), + start (3) end (6) with (appendonly=true, orientation=row), + start (6) end (10) with (appendonly=true, orientation=column) +); +VACUUM AO_AUX_ONLY vac_example_ao; ALTER SYSTEM RESET autovacuum; -- start_ignore \! gpstop -u; diff --git a/src/test/regress/sql/vacuum_ao_aux_only.sql b/src/test/regress/sql/vacuum_ao_aux_only.sql index ec6990da61..858b70658d 100644 --- a/src/test/regress/sql/vacuum_ao_aux_only.sql +++ b/src/test/regress/sql/vacuum_ao_aux_only.sql @@ -103,6 +103,14 @@ FROM gp_segment_configuration WHERE role = 'p' AND content != -1; SELECT gp_inject_fault('vacuum_rel_finished_one_relation', 'reset', dbid) FROM gp_segment_configuration WHERE role = 'p' AND content != -1; +-- test against mixed partitioned appendonly table +CREATE TABLE vac_example_ao(i int, j int) with (appendonly=true, orientation=column) PARTITION BY range (j) +( + start (1) end (3) with (appendonly=false), + start (3) end (6) with (appendonly=true, orientation=row), + start (6) end (10) with (appendonly=true, orientation=column) +); +VACUUM AO_AUX_ONLY vac_example_ao; ALTER SYSTEM RESET autovacuum; -- start_ignore --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
