[FEAT MERGE] del_tenant_memleak branch
Co-authored-by: HaHaJeff <jeffzhouhhh@gmail.com>
This commit is contained in:
@ -44,9 +44,7 @@ public:
|
||||
common::ObClusterVersion::get_instance().update_cluster_version(cluster_version);
|
||||
int ret = OB_SUCCESS;
|
||||
lib::ObMallocAllocator *malloc_allocator = lib::ObMallocAllocator::get_instance();
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID, common::ObCtxIds::WORK_AREA);
|
||||
ret = malloc_allocator->create_and_add_tenant_allocator(OB_SYS_TENANT_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
int s = (int)time(NULL);
|
||||
SQL_ENG_LOG(WARN, "initial setup random seed", K(s));
|
||||
@ -660,4 +658,3 @@ int main(int argc, char **argv)
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -43,8 +43,8 @@ public:
|
||||
lib::ObMallocAllocator *malloc_allocator = lib::ObMallocAllocator::get_instance();
|
||||
//ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID);
|
||||
//ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(
|
||||
OB_SYS_TENANT_ID, common::ObCtxIds::WORK_AREA);
|
||||
ret = malloc_allocator->create_and_add_tenant_allocator(
|
||||
OB_SYS_TENANT_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
int s = (int)time(NULL);
|
||||
LOG_INFO("initial setup random seed", K(s));
|
||||
|
||||
@ -42,7 +42,7 @@ public:
|
||||
lib::ObMallocAllocator *malloc_allocator = lib::ObMallocAllocator::get_instance();
|
||||
//ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID);
|
||||
//ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID, common::ObCtxIds::WORK_AREA);
|
||||
ret = malloc_allocator->create_and_add_tenant_allocator(OB_SYS_TENANT_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
int s = (int)time(NULL);
|
||||
LOG_WARN("initial setup random seed", K(s));
|
||||
|
||||
@ -35,9 +35,7 @@ public:
|
||||
lib::AChunkMgr::instance().set_max_chunk_cache_cnt(0);
|
||||
int ret = OB_SUCCESS;
|
||||
lib::ObMallocAllocator *malloc_allocator = lib::ObMallocAllocator::get_instance();
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID, common::ObCtxIds::WORK_AREA);
|
||||
ret = malloc_allocator->create_and_add_tenant_allocator(OB_SYS_TENANT_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
int s = (int)time(NULL);
|
||||
LOG_INFO("initial setup random seed", K(s));
|
||||
|
||||
@ -396,7 +396,7 @@ int ObHashSetDumpTest::init_tenant_mgr()
|
||||
ulmt,
|
||||
llmt);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
lib::ObTenantCtxAllocator *ctx_allocator =
|
||||
auto ctx_allocator =
|
||||
lib::ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(
|
||||
OB_SERVER_TENANT_ID, common::ObCtxIds::DEFAULT_CTX_ID);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
@ -641,7 +641,7 @@ int ObHashSetDumpTest::init_tenant_mgr()
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
ret = tm.set_tenant_mem_limit(OB_SERVER_TENANT_ID, ulmt, llmt);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
lib::ObTenantCtxAllocator *ctx_allocator =
|
||||
auto ctx_allocator =
|
||||
lib::ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(
|
||||
OB_SERVER_TENANT_ID, common::ObCtxIds::DEFAULT_CTX_ID);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
@ -136,7 +136,7 @@ public:
|
||||
spec9_.plan_ = phy_plan;
|
||||
spec10_.plan_ = phy_plan;
|
||||
spec11_.plan_ = phy_plan;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int init_tenant_mgr();
|
||||
@ -430,7 +430,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int generate_hash_distinct_spec(ObHashDistinctSpec &spec)
|
||||
int generate_hash_distinct_spec(ObHashDistinctSpec &spec)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -699,7 +699,7 @@ protected:
|
||||
int ObHashSetDumpTest::SetPlan::setup_plan(ObOperator *set_op)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_hash = (nullptr != dynamic_cast<ObHashSetOp *> (set_op));
|
||||
bool is_hash = (nullptr != dynamic_cast<ObHashSetOp *> (set_op));
|
||||
bool is_distinct = (nullptr != dynamic_cast<ObHashDistinctOp *> (set_op) || nullptr != dynamic_cast<ObMergeDistinctOp *> (set_op));
|
||||
left_.init_expr(is_hash ? 0 : 30000);
|
||||
right_.init_expr(is_hash ? 0 : 30000);
|
||||
@ -1015,7 +1015,7 @@ int ObHashSetDumpTest::init_tenant_mgr()
|
||||
ulmt,
|
||||
llmt);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
lib::ObTenantCtxAllocator *ctx_allocator =
|
||||
auto ctx_allocator =
|
||||
lib::ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(
|
||||
OB_SERVER_TENANT_ID, common::ObCtxIds::DEFAULT_CTX_ID);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
@ -722,7 +722,7 @@ int ObMergeSetVecTest::init_tenant_mgr()
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
ret = tm.set_tenant_mem_limit(OB_SERVER_TENANT_ID, ulmt, llmt);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
lib::ObTenantCtxAllocator *ctx_allocator =
|
||||
auto ctx_allocator =
|
||||
lib::ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(
|
||||
OB_SERVER_TENANT_ID, common::ObCtxIds::DEFAULT_CTX_ID);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "sql/engine/ob_phy_operator.h"
|
||||
#include "sql/engine/ob_phy_operator_type.h"
|
||||
#include "sql/plan_cache/ob_plan_cache_manager.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/engine/expr/ob_expr_in.h"
|
||||
#include "observer/ob_server.h"
|
||||
|
||||
@ -246,7 +246,6 @@ int ObTestPlanCachePerformance::test(const char * query_str) {
|
||||
context.schema_manager_ = test_sql->get_schema_manager();
|
||||
context.session_info_ = &session_info_;
|
||||
context.partition_location_cache_ = &part_cache_;
|
||||
session_info_.set_plan_cache_manager(sql_engine.get_plan_cache_manager());
|
||||
session_info_.set_plan_cache(sql_engine.get_plan_cache(OB_SYS_TENANT_ID));
|
||||
}
|
||||
|
||||
|
||||
@ -91,66 +91,6 @@ void alter_view_schema_version()
|
||||
view_schema->set_schema_version(schema_version + 1);
|
||||
}
|
||||
|
||||
void print_stat(std::ostream &of) {
|
||||
//print plan cache status
|
||||
int ret = OB_SUCCESS;
|
||||
ObPlanCacheManager::PlanCacheMap::const_iterator it_begin = plan_cache_mgr->get_plan_cache_map().begin();
|
||||
ObPlanCacheManager::PlanCacheMap::const_iterator it_end = plan_cache_mgr->get_plan_cache_map().end();
|
||||
|
||||
for (int i = 1; OB_SUCC(ret) && it_begin != it_end; it_begin++,i++) {
|
||||
of << std::endl;
|
||||
of << "*************** plan cache " << i << " *******************" << std::endl;
|
||||
//do not destroy plan cache
|
||||
ObPlanCache *plan_cache = it_begin->second;
|
||||
if (NULL != plan_cache) {
|
||||
//plan cache stat
|
||||
ObPlanCacheStat &pc_stat = plan_cache->get_plan_cache_stat();
|
||||
of << "plan cache stat:" << "plan_count = " << plan_cache->get_plan_num()
|
||||
<< ", stmtkey_count = " << plan_cache->get_sql_id_mgr()->get_stmtkey2id_map().size()
|
||||
<< ", access_count = " << pc_stat.access_count_
|
||||
<< ", hit_count_ = " << pc_stat.hit_count_
|
||||
<< ", memory_used = " << plan_cache->get_mem_used()
|
||||
<< std::endl;
|
||||
|
||||
//plan stat
|
||||
ObPlanCache::IdStatMap &plan_stat = plan_cache->get_plan_stats();
|
||||
ObPlanCache::IdStatMap::const_iterator mit_begin = plan_stat.begin();
|
||||
ObPlanCache::IdStatMap::const_iterator mit_end = plan_stat.end();
|
||||
for (; OB_SUCC(ret) && mit_begin != mit_end; ++mit_begin) {
|
||||
ObPlanStat pstat = mit_begin->second;
|
||||
of << " plan_id = " << pstat.plan_id_
|
||||
<< ", hit_count = " << pstat.hit_count_
|
||||
<< std::endl;
|
||||
}
|
||||
//ref count
|
||||
of << "plan cache ref_count:" << plan_cache->get_ref_count() << ", tenant id = " << plan_cache->tenant_id_ << std::endl;
|
||||
ObPlanCache::SqlPlanMap::const_iterator v_begin = plan_cache->plan_cache_.begin();
|
||||
ObPlanCache::SqlPlanMap::const_iterator v_end = plan_cache->plan_cache_.end();
|
||||
for (; OB_SUCC(ret) && v_begin != v_end; ++v_begin) {
|
||||
ObPlanCacheValue *value = v_begin->second;
|
||||
if (NULL == value) {continue;}
|
||||
of << " sql_id : " << v_begin->first << ", value ref_count : " << value->get_ref_count() << std::endl;
|
||||
std::string stmt_str(value->get_sql_ptr(), value->get_sql_length());
|
||||
of << " stmt : " << stmt_str << std::endl;
|
||||
DLIST_FOREACH_NORET(plan_set, value->plan_sets_) {
|
||||
if (NULL != plan_set->local_plan_) {
|
||||
of << " plan_id : " << plan_set->local_plan_->plan_id_
|
||||
<< ", plan ref_count :" << plan_set->local_plan_->get_ref_count() << std::endl;
|
||||
}
|
||||
if (NULL != plan_set->remote_plan_) {
|
||||
of << " plan_id : " << plan_set->remote_plan_->plan_id_
|
||||
<< ", plan ref_count :" << plan_set->remote_plan_->get_ref_count() << std::endl;
|
||||
}
|
||||
if (NULL != plan_set->distr_plan_) {
|
||||
of << " plan_id : " << plan_set->distr_plan_->plan_id_
|
||||
<< ", plan ref_count :" << plan_set->distr_plan_->get_ref_count() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//execute one sql
|
||||
void do_operation(const char *query, uint64_t tenant_id)
|
||||
{
|
||||
@ -182,17 +122,21 @@ void do_operation(const char *query, uint64_t tenant_id)
|
||||
int64_t time_9 = 0;
|
||||
// parse
|
||||
time_1 = TestSQL::get_usec();
|
||||
ObPlanCache plan_cache;
|
||||
if (OB_FAIL(test_sql->do_parse(allocator, query, parse_result))) {
|
||||
SQL_PC_LOG(WARN, "Generate syntax tree failed", K(query_str), K(ret));
|
||||
} else if (OB_FAIL(plan_cache.init(common::OB_PLAN_CACHE_BUCKET_NUMBER, tenant_id))) {
|
||||
LOG_WARN("failed to init request manager", K(ret));
|
||||
} else {
|
||||
_OB_LOG(INFO, "%s", CSJ(ObParserResultPrintWrapper(*parse_result.result_tree_)));
|
||||
time_2 = TestSQL::get_usec();
|
||||
// plan cache
|
||||
ObPlanCache *plan_cache = plan_cache_mgr->get_or_create_plan_cache(tenant_id);
|
||||
|
||||
//ObPlanCache *plan_cache = plan_cache_mgr->get_or_create_plan_cache(tenant_id);
|
||||
if (NULL != plan_cache) {
|
||||
plan_cache->set_mem_hwm(HIGH_WATER_MARK);
|
||||
plan_cache->set_mem_lwm(LOW_WATER_MARK);
|
||||
SQL_PC_LOG(INFO, "get plan cache from plan cache mgr", K(plan_cache->ref_count_), K(query_str));
|
||||
plan_cache.set_mem_hwm(HIGH_WATER_MARK);
|
||||
plan_cache.set_mem_lwm(LOW_WATER_MARK);
|
||||
SQL_PC_LOG(INFO, "get plan cache", K(query_str));
|
||||
|
||||
ObSysVarInPC sys_var_in_pc;
|
||||
StmtKey key;
|
||||
@ -213,8 +157,8 @@ void do_operation(const char *query, uint64_t tenant_id)
|
||||
context.schema_manager_ = test_sql->get_schema_manager();
|
||||
context.session_info_ = &session;
|
||||
exec_ctx.get_task_executor_ctx()->set_min_cluster_version(CLUSTER_VERSION_1500);
|
||||
if (NULL != context.schema_manager_ && NULL != plan_cache) {
|
||||
ret = plan_cache->get_plan(allocator, key,
|
||||
if (NULL != context.schema_manager_) {
|
||||
ret = plan_cache.get_plan(allocator, key,
|
||||
exec_ctx,
|
||||
params, sql_id,
|
||||
phy_plan,
|
||||
@ -222,11 +166,11 @@ void do_operation(const char *query, uint64_t tenant_id)
|
||||
SQL_PC_LOG(INFO, "get plan from plan cache", K(sql_id), K(phy_plan), K(ret));
|
||||
time_3 = TestSQL::get_usec();
|
||||
if (OB_SUCC(ret)) {
|
||||
plan_cache->update_plan_stat(phy_plan->get_plan_id(), true, time_7 - time_1);
|
||||
plan_cache.update_plan_stat(phy_plan->get_plan_id(), true, time_7 - time_1);
|
||||
SQL_PC_LOG(INFO, "get plan from pc");
|
||||
} else if (OB_SQL_PC_NOT_EXIST == ret) {
|
||||
SQL_PC_LOG(INFO,"plan not exist in plan cache");
|
||||
plan_cache->update_plan_stat(0, false, 0);
|
||||
plan_cache.update_plan_stat(0, false, 0);
|
||||
// resolve
|
||||
SQL_PC_LOG(INFO, "start to generate physical plan : resolve-->logical_plan-->physical_plan");
|
||||
if (OB_FAIL(test_sql->do_resolve(test_sql_ctx, parse_result, stmt, ¶ms))) {
|
||||
@ -245,14 +189,14 @@ void do_operation(const char *query, uint64_t tenant_id)
|
||||
if (OB_FAIL(test_sql->generate_physical_plan(logical_plan, phy_plan))) {
|
||||
SQL_PC_LOG(WARN, "faile to generate physical plan", K(*logical_plan), K(ret));
|
||||
} else {
|
||||
phy_plan->set_plan_id(plan_cache->allocate_plan_id());
|
||||
phy_plan->set_plan_id(plan_cache.allocate_plan_id());
|
||||
SQL_PC_LOG(INFO, "generate physical plan end", K(phy_plan->get_plan_id()));
|
||||
if (OUTPUT_PHY_PLAN) {
|
||||
SQL_PC_LOG(INFO, "ouput phy plan", K(*phy_plan));
|
||||
}
|
||||
time_6 = TestSQL::get_usec();
|
||||
SQL_PC_LOG(INFO, "add plan to plan cache");
|
||||
ret = plan_cache->add_plan(sql_id,
|
||||
ret = plan_cache.add_plan(sql_id,
|
||||
ObString::make_string(query),
|
||||
sys_var_in_pc,
|
||||
phy_plan,
|
||||
@ -271,7 +215,7 @@ void do_operation(const char *query, uint64_t tenant_id)
|
||||
} else {
|
||||
SQL_PC_LOG(INFO, "Successed to add plan to ObPlanCache");
|
||||
time_7 = TestSQL::get_usec();
|
||||
if (OB_SUCCESS != plan_cache->add_plan_stat(key.db_id_, key.mode_,
|
||||
if (OB_SUCCESS != plan_cache.add_plan_stat(key.db_id_, key.mode_,
|
||||
sql_id, phy_plan)) {
|
||||
SQL_PC_LOG(WARN, "Failed to add plancache stat");
|
||||
}//add plan stat
|
||||
@ -311,8 +255,6 @@ void do_operation(const char *query, uint64_t tenant_id)
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
SQL_PC_LOG(WARN, "schema_manager or plan_cache is NULL", K(ret));
|
||||
}
|
||||
plan_cache->dec_ref_count();
|
||||
SQL_PC_LOG(INFO, "after dec plan cache ref count",K(plan_cache->get_ref_count()));
|
||||
} else {
|
||||
SQL_PC_LOG(WARN, "fail to get or create plan cache");
|
||||
}
|
||||
@ -381,13 +323,15 @@ void test_plan_cache(obsys::CThread *thread, int thread_num, std::ostream &of)
|
||||
}
|
||||
//cache evict
|
||||
if (loop_count % CACHE_EVICT_LOOP_FREQUENCY == 0) {
|
||||
ObPlanCache *plan_cache = plan_cache_mgr->get_plan_cache(tenant_id);
|
||||
if (NULL != plan_cache) {
|
||||
|
||||
ObPlanCache plan_cache;
|
||||
if (OB_FAIL(plan_cache.init(common::OB_PLAN_CACHE_BUCKET_NUMBER, tenant_id))) {
|
||||
LOG_WARN("failed to init request manager", K(ret));
|
||||
} else {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (tmp_ret = plan_cache->cache_evict())) {
|
||||
if (OB_SUCCESS != (tmp_ret = plan_cache.cache_evict())) {
|
||||
SQL_PC_LOG(ERROR, "plan cache evict failed, please check");
|
||||
}
|
||||
plan_cache->dec_ref_count();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,126 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX SQL
|
||||
#include <unistd.h>
|
||||
#include "lib/json/ob_json.h"
|
||||
#include "test_sql.h"
|
||||
#include "lib/allocator/ob_malloc.h"
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::json;
|
||||
using namespace oceanbase::share::schema;
|
||||
|
||||
namespace test
|
||||
{
|
||||
static int MAX_THREAD_COUNT = 1;
|
||||
static uint64_t TENANT_ID_NUM = 1;
|
||||
|
||||
static TestSQL *test_sql = NULL;
|
||||
static ObPlanCacheManager *plan_cache_mgr = NULL;
|
||||
|
||||
void init_pcm()
|
||||
{
|
||||
if (NULL == test_sql) {
|
||||
test_sql = new TestSQL(ObString("test_schema.sql"));
|
||||
ASSERT_TRUE(test_sql);
|
||||
test_sql->init();
|
||||
}
|
||||
if (NULL == plan_cache_mgr) {
|
||||
plan_cache_mgr = new ObPlanCacheManager;
|
||||
plan_cache_mgr->init(test_sql->get_part_cache(), test_sql->get_addr());
|
||||
}
|
||||
}
|
||||
|
||||
class TestPlanCacheManager : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
TestPlanCacheManager() {}
|
||||
virtual ~TestPlanCacheManager() {}
|
||||
void SetUp() {}
|
||||
void TearDown() {}
|
||||
private:
|
||||
// disallow copy
|
||||
TestPlanCacheManager(const TestPlanCacheManager &other);
|
||||
TestPlanCacheManager& operator=(const TestPlanCacheManager &other);
|
||||
};
|
||||
|
||||
void test_plan_cache_manager()
|
||||
{
|
||||
uint64_t tenant_id = 0;
|
||||
ObPlanCache *plan_cache = NULL;
|
||||
|
||||
//test get_plan_cache()
|
||||
ObPCMemPctConf conf;
|
||||
for (tenant_id = 0; tenant_id < TENANT_ID_NUM; tenant_id++) {
|
||||
plan_cache = plan_cache_mgr->get_plan_cache(tenant_id);
|
||||
plan_cache = plan_cache_mgr->get_or_create_plan_cache(tenant_id, conf);//may be plan_cache = NULL in parallel
|
||||
LOG_INFO("get_plan_cache",K(tenant_id), K(plan_cache));
|
||||
//ob_print_mod_memory_usage();
|
||||
if (TENANT_ID_NUM/2 == tenant_id) {
|
||||
plan_cache_mgr->elimination_task_.runTimerTask();
|
||||
}
|
||||
}
|
||||
|
||||
//test revert_plan_cache()
|
||||
EXPECT_TRUE(OB_SUCCESS == plan_cache_mgr->revert_plan_cache(TENANT_ID_NUM - 1));
|
||||
EXPECT_TRUE(OB_SUCCESS == plan_cache_mgr->revert_plan_cache(TENANT_ID_NUM + 1));
|
||||
}
|
||||
|
||||
class ObPlanCacheManagerRunnable : public share::ObThreadPool
|
||||
{
|
||||
public:
|
||||
void run1()
|
||||
{
|
||||
test_plan_cache_manager();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TestPlanCacheManager, basic)
|
||||
{
|
||||
// test
|
||||
ObPlanCacheManagerRunnable pcm_runner;
|
||||
for (int i = 0; i < MAX_THREAD_COUNT; ++i) {
|
||||
pcm_runner.start();
|
||||
}
|
||||
for (int i = 0; i < MAX_THREAD_COUNT; ++i) {
|
||||
pcm_runner.wait();
|
||||
}
|
||||
|
||||
EXPECT_TRUE(OB_SUCCESS == plan_cache_mgr->flush_all_plan_cache());
|
||||
plan_cache_mgr->destroy(); }
|
||||
}//namespace test end
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::oceanbase::sql::init_sql_factories();
|
||||
::testing::InitGoogleTest(&argc,argv);
|
||||
|
||||
int c = 0;
|
||||
while(-1 != (c = getopt(argc, argv, "t::n::"))) {
|
||||
switch (c) {
|
||||
case 't':
|
||||
if (NULL != optarg) {
|
||||
test::MAX_THREAD_COUNT = atoi(optarg);
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
if (NULL != optarg) {
|
||||
test::TENANT_ID_NUM = atoi(optarg);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
::test::init_pcm();
|
||||
return RUN_ALL_TESTS();
|
||||
}//namespace test end
|
||||
@ -21,6 +21,8 @@
|
||||
#include "sql/engine/cmd/ob_partition_executor_utils.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "optimizer/ob_mock_opt_stat_manager.h"
|
||||
#include "sql/plan_cache/ob_plan_cache.h"
|
||||
#include "sql/plan_cache/ob_ps_cache.h"
|
||||
#define CLUSTER_VERSION_2100 (oceanbase::common::cal_version(2, 1, 0, 0))
|
||||
#define CLUSTER_VERSION_2200 (oceanbase::common::cal_version(2, 2, 0, 0))
|
||||
using namespace oceanbase::observer;
|
||||
@ -249,17 +251,19 @@ void TestSqlUtils::init()
|
||||
int64_t default_collation = 45; // utf8mb4_general_ci
|
||||
ASSERT_TRUE(OB_SUCCESS == session_info_.update_sys_variable(SYS_VAR_COLLATION_CONNECTION, default_collation));
|
||||
ObAddr addr;
|
||||
if (OB_FAIL(plan_cache_mgr_.init(addr))) {
|
||||
OB_LOG(WARN,"fail to init plan cache manager", K(ret));
|
||||
}
|
||||
ObPlanCache* pc = new ObPlanCache();
|
||||
ObPsCache* ps = new ObPsCache();
|
||||
ObPCMemPctConf pc_mem_conf;
|
||||
if (OB_FAIL(session_info_.get_pc_mem_conf(pc_mem_conf))) {
|
||||
if (OB_FAIL(pc->init(common::OB_PLAN_CACHE_BUCKET_NUMBER, tenant_id))) {
|
||||
LOG_WARN("failed to init request manager", K(ret));
|
||||
} else if (OB_FAIL(ps->init(common::OB_PLAN_CACHE_BUCKET_NUMBER, tenant_id))) {
|
||||
LOG_WARN("failed to init request manager", K(ret));
|
||||
} else if (OB_FAIL(session_info_.get_pc_mem_conf(pc_mem_conf))) {
|
||||
_OB_LOG(WARN,"fail to get pc mem conf, ret=%ld", ret);
|
||||
ASSERT_TRUE(0);
|
||||
} else {
|
||||
session_info_.set_plan_cache_manager(&plan_cache_mgr_);
|
||||
session_info_.set_plan_cache(plan_cache_mgr_.get_or_create_plan_cache(tenant_id, pc_mem_conf));
|
||||
session_info_.set_ps_cache(plan_cache_mgr_.get_or_create_ps_cache(tenant_id, pc_mem_conf));
|
||||
session_info_.set_plan_cache(pc);
|
||||
session_info_.set_ps_cache(ps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -268,6 +272,8 @@ void TestSqlUtils::init()
|
||||
|
||||
void TestSqlUtils::destroy()
|
||||
{
|
||||
ObPlanCache* pc = session_info_.get_plan_cache();
|
||||
ObPsCache* ps = session_info_.get_ps_cache();
|
||||
sys_user_id_ = OB_SYS_USER_ID;
|
||||
next_user_id_ = OB_MIN_USER_OBJECT_ID;
|
||||
sys_database_id_ = OB_SYS_DATABASE_ID;
|
||||
@ -286,6 +292,12 @@ void TestSqlUtils::destroy()
|
||||
if (NULL != schema_service_) {
|
||||
delete schema_service_;
|
||||
}
|
||||
if (NULL != ps) {
|
||||
delete ps;
|
||||
}
|
||||
if (NULL != pc) {
|
||||
delete pc;
|
||||
}
|
||||
ObKVGlobalCache::get_instance().destroy();
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
#include "sql/executor/ob_task_executor_ctx.h"
|
||||
#include "sql/ob_sql_context.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "sql/plan_cache/ob_plan_cache_manager.h"
|
||||
#include "../share/schema/mock_schema_service.h"
|
||||
|
||||
using namespace oceanbase;
|
||||
@ -159,7 +158,6 @@ public:
|
||||
ObSqlCtx sql_ctx_;
|
||||
ObExecContext exec_ctx_;
|
||||
ParamStore param_list_;
|
||||
ObPlanCacheManager plan_cache_mgr_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(TestSqlUtils);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user