From 5fd2b404fb3634a8828d7bc570906ac1ec5d90b8 Mon Sep 17 00:00:00 2001 From: openGaussDev Date: Thu, 21 Mar 2024 14:16:31 +0800 Subject: [PATCH] submit code to openGauss-serverOffering: openGaussDevMore detail:fix index only scan pro Match-id-47e355502b9f0d5905ad914311743ea21d937d60 --- src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp | 5 +++-- .../runtime/opfusion/opfusion_indexonlyscan.cpp | 4 +++- src/include/access/multi_redo_api.h | 7 +++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp b/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp index a15e60519c..db613fd211 100644 --- a/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp +++ b/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp @@ -42,6 +42,7 @@ #include "utils/rel_gs.h" #include "nodes/makefuncs.h" #include "optimizer/pruning.h" +#include "access/multi_redo_api.h" static TupleTableSlot* ExecIndexOnlyScan(PlanState* state); @@ -187,8 +188,8 @@ static TupleTableSlot* IndexOnlyNext(IndexOnlyScanState* node) continue; /* the visible version not match the IndexTuple */ } } - } else if (isVersionScan || - !visibilitymap_test(indexScan->heapRelation, ItemPointerGetBlockNumber(tid), &node->ioss_VMBuffer)) { + } else if (isVersionScan || is_index_only_disabled_in_astore() || + !visibilitymap_test(indexScan->heapRelation, ItemPointerGetBlockNumber(tid), &node->ioss_VMBuffer)) { /* IMPORTANT: We ALWAYS visit the heap to check visibility in VERSION SCAN. */ /* * Rats, we have to visit the heap to check visibility. diff --git a/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp b/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp index 6bace98ab8..e3f3e19f26 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp @@ -29,6 +29,7 @@ #include "access/visibilitymap.h" #include "opfusion/opfusion_util.h" #include "utils/knl_partcache.h" +#include "access/multi_redo_api.h" IndexOnlyScanFusion::IndexOnlyScanFusion(IndexOnlyScan* node, PlannedStmt* planstmt, ParamListInfo params) @@ -272,7 +273,8 @@ TupleTableSlot *IndexOnlyScanFusion::getTupleSlotInternal() } /* UStore don't have visibility map */ - if (isUStore || !visibilitymap_test(indexdesc->heapRelation, ItemPointerGetBlockNumber(tid), &m_VMBuffer)) { + if (isUStore || is_index_only_disabled_in_astore() || + !visibilitymap_test(indexdesc->heapRelation, ItemPointerGetBlockNumber(tid), &m_VMBuffer)) { tuple = (HeapTuple)IndexFetchTuple(indexdesc); if (tuple == NULL) { continue; /* no visible tuple, try next index entry */ diff --git a/src/include/access/multi_redo_api.h b/src/include/access/multi_redo_api.h index cf4d38f714..460e9f44e4 100644 --- a/src/include/access/multi_redo_api.h +++ b/src/include/access/multi_redo_api.h @@ -114,6 +114,13 @@ static inline bool IsMultiThreadRedo() return (get_real_recovery_parallelism() > 1); } +inline bool is_index_only_disabled_in_astore() +{ + return (RecoveryInProgress() && + (IsParallelRedo() || + (IsExtremeRedo() && g_instance.attr.attr_storage.enable_exrto_standby_read_opt))); +} + uint32 GetRedoWorkerCount(); bool IsMultiThreadRedoRunning(); void DispatchRedoRecord(XLogReaderState* record, List* expectedTLIs, TimestampTz recordXTime); -- Gitee