This is an automated email from the ASF dual-hosted git repository.

avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 5cc58d6e24ed9e4fbb284662af348f3ef5215f56
Author: Soumyadeep Chakraborty <[email protected]>
AuthorDate: Thu Dec 15 20:32:03 2022 -0800

    ao/co: Clarify compute_xid_horizon_for_tuples API
    
    This removes FIXMEs for the compute_xid_horizon_for_tuples() API, which
    was introduced in 558a9165e08.
    
    This API is used to compute what snapshots to conflict with when
    replaying WAL records for page-level index vacuums. Page-level index
    vacuums don't even arise for AO/CO tables today due to absence of HOT.
    Thus it is perfectly fine to leave this unimplemented.
    
    Details:
    
    (1) The amgettuple() routine for index AMs can optionally kill off
    tuples if they are found dead in the underlying table scan. This is done
    with IndexScanDesc->kill_prior_tuple. For examples: see btgettuple(),
    hashgettuple() and gistgettuple().
    
    (2) The index AMs typically have a killitems function (like
    _bt_killitems()), which among other things sets a garbage flag on the
    index page (like BTP_HAS_GARBAGE)
    
    (3) Afterwards, if an index page has a garbage flag, it can undergo page
    level vacuum, even inside a scan (see _bt_vacuum_one_page()). This is
    where table_compute_xid_horizon_for_tuples() is typically called and the
    latestRemovedXid is recorded in the WAL (eg XLOG_BTREE_DELETE).
    
    (4) During replay on a hot standby, the latestRemovedXid is extracted
    from the record and then used to ResolveRecoveryConflictWithSnapshot().
    
    Since, AO/CO tables don't have HOT chains, in index_fetch_heap(),
    all_dead is always set to false and thus the
    IndexScanDesc->kill_prior_tuple is always false. Thus, we never even
    perform index page-level vacuum for indexes on AO/CO tables, let alone
    compute the xid horizon.
---
 src/backend/access/aocs/aocsam_handler.c             | 13 +++++++++++--
 src/backend/access/appendonly/appendonlyam_handler.c | 13 +++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/aocs/aocsam_handler.c 
b/src/backend/access/aocs/aocsam_handler.c
index 86b55ac1dc..d91c913f87 100644
--- a/src/backend/access/aocs/aocsam_handler.c
+++ b/src/backend/access/aocs/aocsam_handler.c
@@ -1269,8 +1269,17 @@ static TransactionId
 aoco_index_delete_tuples(Relation rel,
                                                 TM_IndexDeleteOp *delstate)
 {
-       // GPDB_14_MERGE_FIXME: vacuum related call back.
-       elog(ERROR, "not implemented yet");
+       /*
+        * This API is only useful for hot standby snapshot conflict resolution
+        * (for eg. see btree_xlog_delete()), in the context of index page-level
+        * vacuums (aka page-level cleanups). This operation is only done when
+        * IndexScanDesc->kill_prior_tuple is true, which is never for AO/CO 
tables
+        * (we always return all_dead = false in the index_fetch_tuple() 
callback
+        * as we don't support HOT)
+        */
+       ereport(ERROR,
+                       (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                               errmsg("feature not supported on 
appendoptimized relations")));
 }
 
 
diff --git a/src/backend/access/appendonly/appendonlyam_handler.c 
b/src/backend/access/appendonly/appendonlyam_handler.c
index 41c7d00157..4f4fd969dd 100644
--- a/src/backend/access/appendonly/appendonlyam_handler.c
+++ b/src/backend/access/appendonly/appendonlyam_handler.c
@@ -888,8 +888,17 @@ static TransactionId
 appendonly_index_delete_tuples(Relation rel,
                                                 TM_IndexDeleteOp *delstate)
 {
-       // GPDB_14_MERGE_FIXME: vacuum related call back.
-       elog(ERROR, "not implemented yet");
+       /*
+        * This API is only useful for hot standby snapshot conflict resolution
+        * (for eg. see btree_xlog_delete()), in the context of index page-level
+        * vacuums (aka page-level cleanups). This operation is only done when
+        * IndexScanDesc->kill_prior_tuple is true, which is never for AO/CO 
tables
+        * (we always return all_dead = false in the index_fetch_tuple() 
callback
+        * as we don't support HOT)
+        */
+       ereport(ERROR,
+                       (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                               errmsg("feature not supported on 
appendoptimized relations")));
 }
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to