From a3cf9e4b3c648c51ff5dd02d8761283334fcd567 Mon Sep 17 00:00:00 2001 From: shirley_zhengx Date: Mon, 27 Dec 2021 13:14:53 +0800 Subject: [PATCH 1/3] fix bug for local index with fastupdate for partition --- src/common/backend/utils/cache/partcache.cpp | 24 +++++++++++++++++++ .../storage/access/common/heaptuple.cpp | 1 + src/include/utils/partcache.h | 1 + 3 files changed, 26 insertions(+) diff --git a/src/common/backend/utils/cache/partcache.cpp b/src/common/backend/utils/cache/partcache.cpp index c746d96cc..66cdac1d1 100644 --- a/src/common/backend/utils/cache/partcache.cpp +++ b/src/common/backend/utils/cache/partcache.cpp @@ -1947,6 +1947,30 @@ void PartitionSetWaitCleanGpi(Oid partOid, bool enable, bool inplace) ereport(LOG, (errmsg("partition %u set reloptions wait_clean_gpi success", partOid))); } +/* + * check one partition's invisible metadata whether need to skip the check of gpi for global index + * + * Notes: if datumPartType is 'x', that is local index of one partiiton, this case can skip the check + * of wait_clean_gpi for partition's global index + */ +bool PartitionLocalIndexSkipping(Datum datumPartType); +{ + char parttype; + + if (!PointerIsValid(datumPartType)) { + return false; + } + + parttype = DatumGetChar(datumPartType); + if (parttype == PART_OBJ_TYPE_INDEX_PARTITION) { + return false; + + } + + return true; + +} + /* * Check one partition's invisible metadata tuple whether still keep * diff --git a/src/gausskernel/storage/access/common/heaptuple.cpp b/src/gausskernel/storage/access/common/heaptuple.cpp index 3e8980092..a6b277a06 100644 --- a/src/gausskernel/storage/access/common/heaptuple.cpp +++ b/src/gausskernel/storage/access/common/heaptuple.cpp @@ -3281,6 +3281,7 @@ void heap_slot_store_heap_tuple(HeapTuple tuple, TupleTableSlot* slot, Buffer bu bool HeapKeepInvisbleTuple(HeapTuple tuple, TupleDesc tupleDesc, KeepInvisbleTupleFunc checkKeepFunc) { static KeepInvisbleOpt keepInvisibleArray[] = { + {PartitionRelationId, Anum_pg_partition_parttypt}, PartitionLocalIndexSkipping}, {PartitionRelationId, Anum_pg_partition_reloptions, PartitionInvisibleMetadataKeep}, {PartitionRelationId, Anum_pg_partition_parentid, PartitionParentOidIsLive}}; diff --git a/src/include/utils/partcache.h b/src/include/utils/partcache.h index a4618cdee..09f1e57dd 100644 --- a/src/include/utils/partcache.h +++ b/src/include/utils/partcache.h @@ -92,6 +92,7 @@ extern PartStatus PartitionGetMetadataStatus(Oid partOid, bool vacuumFlag); extern Datum SetWaitCleanGpiRelOptions(Datum oldOptions, bool enable); extern void PartitionedSetWaitCleanGpi(const char* parentName, Oid parentPartOid, bool enable, bool inplace); extern void PartitionSetWaitCleanGpi(Oid partOid, bool enable, bool inplace); +extern bool PartitionLocalIndexSkipping(Datum datumPartType); extern bool PartitionInvisibleMetadataKeep(Datum datumRelOptions); extern bool PartitionParentOidIsLive(Datum parentDatum); extern void PartitionedSetEnabledClean(Oid parentOid); From 2a46352f5fbdf19a4dd07659a837439fb55d8d2b Mon Sep 17 00:00:00 2001 From: shirley_zhengx Date: Mon, 27 Dec 2021 19:03:44 +0800 Subject: [PATCH 2/3] modify parameter --- src/common/backend/utils/cache/partcache.cpp | 2 +- src/gausskernel/storage/access/common/heaptuple.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/backend/utils/cache/partcache.cpp b/src/common/backend/utils/cache/partcache.cpp index 66cdac1d1..3f964c332 100644 --- a/src/common/backend/utils/cache/partcache.cpp +++ b/src/common/backend/utils/cache/partcache.cpp @@ -1953,7 +1953,7 @@ void PartitionSetWaitCleanGpi(Oid partOid, bool enable, bool inplace) * Notes: if datumPartType is 'x', that is local index of one partiiton, this case can skip the check * of wait_clean_gpi for partition's global index */ -bool PartitionLocalIndexSkipping(Datum datumPartType); +bool PartitionLocalIndexSkipping(Datum datumPartType) { char parttype; diff --git a/src/gausskernel/storage/access/common/heaptuple.cpp b/src/gausskernel/storage/access/common/heaptuple.cpp index a6b277a06..2ac2ce997 100644 --- a/src/gausskernel/storage/access/common/heaptuple.cpp +++ b/src/gausskernel/storage/access/common/heaptuple.cpp @@ -3281,7 +3281,7 @@ void heap_slot_store_heap_tuple(HeapTuple tuple, TupleTableSlot* slot, Buffer bu bool HeapKeepInvisbleTuple(HeapTuple tuple, TupleDesc tupleDesc, KeepInvisbleTupleFunc checkKeepFunc) { static KeepInvisbleOpt keepInvisibleArray[] = { - {PartitionRelationId, Anum_pg_partition_parttypt}, PartitionLocalIndexSkipping}, + {PartitionRelationId, Anum_pg_partition_parttype, PartitionLocalIndexSkipping}, {PartitionRelationId, Anum_pg_partition_reloptions, PartitionInvisibleMetadataKeep}, {PartitionRelationId, Anum_pg_partition_parentid, PartitionParentOidIsLive}}; From a5da5b5264cd39d42cdbd12c636f74e05189d529 Mon Sep 17 00:00:00 2001 From: shirley_zhengx Date: Mon, 27 Dec 2021 19:06:46 +0800 Subject: [PATCH 3/3] modify parameter --- src/common/backend/utils/cache/partcache.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/common/backend/utils/cache/partcache.cpp b/src/common/backend/utils/cache/partcache.cpp index 3f964c332..68e3ccae5 100644 --- a/src/common/backend/utils/cache/partcache.cpp +++ b/src/common/backend/utils/cache/partcache.cpp @@ -1963,12 +1963,10 @@ bool PartitionLocalIndexSkipping(Datum datumPartType) parttype = DatumGetChar(datumPartType); if (parttype == PART_OBJ_TYPE_INDEX_PARTITION) { - return false; - + return false; } return true; - } /*