From e95704403354ba50a6b42f952a6da33afe4d1b38 Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 1 Sep 2023 06:40:42 +0000 Subject: [PATCH] Add Ob2DTMArray to solve sys_tenant memory problem caused by ObPxTabletRange --- deps/oblib/src/lib/container/ob_2d_array.h | 8 ++++--- src/sql/engine/px/ob_px_dtl_msg.h | 5 ++-- src/sql/ob_sql_define.h | 27 +++++++++++++++++++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/deps/oblib/src/lib/container/ob_2d_array.h b/deps/oblib/src/lib/container/ob_2d_array.h index 3e286559bf..6fb57c9314 100644 --- a/deps/oblib/src/lib/container/ob_2d_array.h +++ b/deps/oblib/src/lib/container/ob_2d_array.h @@ -73,12 +73,14 @@ public: static uint32_t capacity_offset_bits() { return offsetof(Ob2DArray, capacity_) * 8; } NEED_SERIALIZE_AND_DESERIALIZE; -private: - using MyOp = ObClassOp::value>; - // function members + +protected: template int inner_assign(const U &other); +private: + using MyOp = ObClassOp::value>; + // function members void construct_items(T *ptr, int64_t cnt); int set_default(const int64_t new_size); T *get_obj_pos(int64_t i) const; diff --git a/src/sql/engine/px/ob_px_dtl_msg.h b/src/sql/engine/px/ob_px_dtl_msg.h index db0b929542..8f632a1408 100644 --- a/src/sql/engine/px/ob_px_dtl_msg.h +++ b/src/sql/engine/px/ob_px_dtl_msg.h @@ -26,6 +26,7 @@ #include "lib/compress/ob_compress_util.h" #include "storage/tx/ob_trans_define.h" #include "sql/engine/ob_exec_feedback_info.h" +#include "sql/ob_sql_define.h" namespace oceanbase { @@ -545,9 +546,9 @@ public: public: static const int64_t DEFAULT_RANGE_COUNT = 8; typedef common::ObSEArray EndKeys; - typedef Ob2DArray DatumKey; + typedef ObTMSegmentArray DatumKey; typedef ObSEArray RangeWeight; - typedef ObSEArray RangeCut; // not include MAX at last nor MIN at first + typedef ObTMArray RangeCut; // not include MAX at last nor MIN at first typedef ObSEArray RangeWeights; int64_t tablet_id_; diff --git a/src/sql/ob_sql_define.h b/src/sql/ob_sql_define.h index 08d69c7c4f..47dff5244e 100644 --- a/src/sql/ob_sql_define.h +++ b/src/sql/ob_sql_define.h @@ -19,6 +19,7 @@ #include "share/ob_define.h" #include "deps/oblib/src/lib/container/ob_array.h" #include "src/share/rc/ob_tenant_base.h" +#include "deps/oblib/src/lib/container/ob_2d_array.h" namespace oceanbase { @@ -487,7 +488,7 @@ enum DominateRelation OBJ_UNCOMPARABLE }; -// for parallel precedence, refer to +// for parallel precedence, refer to // https://docs.oracle.com/cd/E11882_01/server.112/e41573/hintsref.htm#PFGRF94937 enum PXParallelRule { @@ -624,6 +625,30 @@ ObTMArray::ObTMArray(int64_ this->set_tenant_id(MTL_ID()); } +template > +class ObTMSegmentArray final : public Ob2DArray +{ +public: + ObTMSegmentArray(const BlockAllocatorT &alloc = BlockAllocatorT("TMSegmentArray")); + int assign(const ObTMSegmentArray &other) { return this->inner_assign(other); } +}; + +template +ObTMSegmentArray::ObTMSegmentArray(const BlockAllocatorT &alloc) + : Ob2DArray(alloc) +{ + this->set_tenant_id(MTL_ID()); +} + } // namespace sql } // namespace oceanbase #endif /* OCEANBASE_SQL_OB_SQL_DEFINE_H_ */