提交 0cf6476d 编写于 作者: A Ashwin Agrawal

Skip persistent tables in VACUUM

Vacuum lazy is harmless, but also no benefit to perform just extra work.
Vacuum full could turn out dangerous as it has potential to move tuples
around causing the TIDs for tuples to change, which violates its reference
from gp_relation_node. In general persistent table has all frozen tuples
so vacuum full is harmless too, but for example one scenario where it becomes
dangerous is zero-page case due to failure after page extension but before
page initialization. Also, since all the tuples in persistent table are
frozen inserts, skip it from database age calculation.
上级 7f49de73
......@@ -1448,6 +1448,16 @@ get_rel_oids(List *relids, const RangeVar *vacrel, const char *stmttype,
classForm->relstorage == RELSTORAGE_VIRTUAL))
continue;
/* Skip persistent tables. Vacuum lazy is harmless, but also no
* benefit to perform. Vacuum full could turn out dangerous as it
* has potential to move tuples around causing the TIDs for tuples
* to change, which violates its reference from
* gp_relation_node. One scenario where this can happen is zero-page
* due to failure after page extension but before page initialization.
*/
if (GpPersistent_IsPersistentRelation(HeapTupleGetOid(tuple)))
continue;
/* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context);
oid_list = lappend_oid(oid_list, HeapTupleGetOid(tuple));
......@@ -1772,6 +1782,10 @@ vac_update_datfrozenxid(void)
classForm->relstorage == RELSTORAGE_VIRTUAL))
continue;
/* exclude persistent tables, as all updates to it are frozen */
if (GpPersistent_IsPersistentRelation(HeapTupleGetOid(classTup)))
continue;
Assert(TransactionIdIsNormal(classForm->relfrozenxid));
if (TransactionIdPrecedes(classForm->relfrozenxid, newFrozenXid))
......@@ -5370,7 +5384,9 @@ open_relation_and_check_permission(VacuumStmt *vacstmt,
* Check that it's a plain table; we used to do this in get_rel_oids() but
* seems safer to check after we've locked the relation.
*/
if (onerel->rd_rel->relkind != expected_relkind || RelationIsExternal(onerel))
if (onerel->rd_rel->relkind != expected_relkind ||
RelationIsExternal(onerel) ||
GpPersistent_IsPersistentRelation(RelationGetRelid(onerel)))
{
ereport(WARNING,
(errmsg("skipping \"%s\" --- cannot vacuum indexes, views, external tables, or special system tables",
......
......@@ -275,4 +275,8 @@ create table ao_t1(a int, b int) with (appendonly=true) distributed by(a);
insert into ao_t1 select i, i from generate_series(1, 10000) i;
update ao_t1 set b = b + 1;
vacuum full ao_t1;
drop table ao_t1;
drop table ao_t0;
vacuum gp_persistent_relation_node;
WARNING: skipping "gp_persistent_relation_node" --- cannot vacuum indexes, views, external tables, or special system tables
vacuum full gp_persistent_relation_node;
WARNING: skipping "gp_persistent_relation_node" --- cannot vacuum indexes, views, external tables, or special system tables
......@@ -181,3 +181,6 @@ insert into ao_t1 select i, i from generate_series(1, 10000) i;
update ao_t1 set b = b + 1;
vacuum full ao_t1;
drop table ao_t1;
vacuum gp_persistent_relation_node;
vacuum full gp_persistent_relation_node;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册