Merge branch 'column_store'

Co-authored-by: wangt1xiuyi <13547954130@163.com>
Co-authored-by: yangqise7en <877793735@qq.com>
Co-authored-by: Zach41 <zach_41@163.com>
This commit is contained in:
chaser-ch
2023-10-31 15:39:20 +00:00
committed by ob-robot
parent 4057fbc4ae
commit 566e920620
1375 changed files with 239147 additions and 56014 deletions

View File

@ -16,7 +16,7 @@
#define protected public
#include "share/scheduler/ob_dag_warning_history_mgr.h"
#include "share/scheduler/ob_dag_scheduler.h"
#include "share/scheduler/ob_tenant_dag_scheduler.h"
#include "storage/ob_sstable_struct.h"
#include "observer/omt/ob_tenant_node_balancer.h"
@ -29,21 +29,27 @@ using namespace lib;
namespace unittest
{
static const int64_t INFO_PAGE_SIZE = (1 << 11); // 2KB
static const int64_t INFO_PAGE_SIZE = (1 << 12); // 4KB
class TestDagWarningHistory : public ::testing::Test
{
public:
TestDagWarningHistory()
: tenant_id_(1),
: tenant_id_(1001),
dag_history_mgr_(nullptr),
tenant_base_(tenant_id_)
tenant_base_(1001),
inited_(false)
{ }
~TestDagWarningHistory() {}
void SetUp()
{
if (!inited_) {
ObMallocAllocator::get_instance()->create_and_add_tenant_allocator(tenant_id_);
ObMallocAllocator::get_instance()->set_tenant_limit(tenant_id_, 1LL << 30);
inited_ = true;
}
ObUnitInfoGetter::ObTenantConfig unit_config;
unit_config.mode_ = lib::Worker::CompatMode::MYSQL;
unit_config.tenant_id_ = tenant_id_;
unit_config.tenant_id_ = 0;
TenantUnits units;
ASSERT_EQ(OB_SUCCESS, units.push_back(unit_config));
@ -53,9 +59,6 @@ public:
ObTenantEnv::set_tenant(&tenant_base_);
ASSERT_EQ(OB_SUCCESS, tenant_base_.init());
ObMallocAllocator *ma = ObMallocAllocator::get_instance();
ASSERT_EQ(OB_SUCCESS, ma->create_and_add_tenant_allocator(tenant_id_));
ASSERT_EQ(OB_SUCCESS, ma->set_tenant_limit(tenant_id_, 1LL << 30));
}
void TearDown()
{
@ -68,6 +71,7 @@ private:
const uint64_t tenant_id_;
ObDagWarningHistoryManager *dag_history_mgr_;
ObTenantBase tenant_base_;
bool inited_;
DISALLOW_COPY_AND_ASSIGN(TestDagWarningHistory);
};
@ -153,6 +157,7 @@ TEST_F(TestDagWarningHistory, simple_add)
dag.init();
dag.set_dag_ret(ObBasicDag::DAG_RET_START);
dag.set_dag_status(ObBasicDag::ObDagStatus::DAG_STATUS_ABORT);
STORAGE_LOG(DEBUG, "hash print", K(dag.hash()));
//not init
ret = MTL(ObDagWarningHistoryManager *)->add_dag_warning_info(&dag);
@ -289,7 +294,7 @@ TEST_F(TestDagWarningHistory, resize)
ret = MTL(ObDagWarningHistoryManager *)->init(true, MTL_ID(), "DagWarnHis", INFO_PAGE_SIZE);
ASSERT_EQ(OB_SUCCESS, ret);
const int64_t max_cnt = 20;
const int64_t max_cnt = 40;
for (int i = 0; i < max_cnt; ++i) {
ObSeqDag dag;
dag.init();
@ -300,15 +305,15 @@ TEST_F(TestDagWarningHistory, resize)
ASSERT_EQ(max_cnt, MTL(ObDagWarningHistoryManager *)->size());
// every info is 240 bytes, each page contains 7 info
// 20 infos are in 3 pages (7 7 6), set_max will left 6 info (6 * 240 < 4096 * 0.4), means 1 page (6)
// every info is 264 bytes, each page contains 13 info
// 40 infos are in 4 pages (13 13 13 1), set_max will left 12 info (12 * 264 < 4096 * 0.4), means 2 page (11 1)
ret = MTL(ObDagWarningHistoryManager *)->set_max(2 * INFO_PAGE_SIZE);
ASSERT_EQ(OB_SUCCESS, ret);
ASSERT_EQ(6, MTL(ObDagWarningHistoryManager *)->size());
ASSERT_EQ(12, MTL(ObDagWarningHistoryManager *)->size());
ret = MTL(ObDagWarningHistoryManager *)->set_max(3 * INFO_PAGE_SIZE);
ASSERT_EQ(OB_SUCCESS, ret);
ASSERT_EQ(6, MTL(ObDagWarningHistoryManager *)->size());
ASSERT_EQ(12, MTL(ObDagWarningHistoryManager *)->size());
compaction::ObIDiagnoseInfoMgr::Iterator iterator;
ret = MTL(ObDagWarningHistoryManager *)->open_iter(iterator);
@ -316,7 +321,7 @@ TEST_F(TestDagWarningHistory, resize)
ObDagWarningInfo read_info;
char comment[common::OB_DAG_WARNING_INFO_LENGTH];
int i = 14;
int i = 28;
while (OB_SUCC(ret)) {
if (OB_FAIL(iterator.get_next(&read_info, comment, sizeof(comment)))) {
ASSERT_EQ(OB_ITER_END, ret);
@ -330,7 +335,6 @@ TEST_F(TestDagWarningHistory, resize)
TEST_F(TestDagWarningHistory, gc_info)
{
int ret = OB_SUCCESS;
ObDagWarningHistoryManager* manager = MTL(ObDagWarningHistoryManager *);
ASSERT_TRUE(nullptr != manager);
ret = MTL(ObDagWarningHistoryManager *)->init(true, MTL_ID(), "DagWarnHis", INFO_PAGE_SIZE);
@ -339,7 +343,7 @@ TEST_F(TestDagWarningHistory, gc_info)
ASSERT_EQ(OB_SUCCESS, ret);
int64_t hash_value = ObBasicDag::KEY_START;
const int64_t max_cnt = 69;
const int64_t max_cnt = 129;
for (int i = 0; i < max_cnt; ++i) {
ObComplexDag dag(hash_value++);
dag.init();
@ -347,17 +351,17 @@ TEST_F(TestDagWarningHistory, gc_info)
dag.set_dag_ret(ObBasicDag::DAG_RET_START + i);
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->add_dag_warning_info(&dag));
}
// 9 page full, 1 page contain 6 info (7 7 7 7 7 7 7 7 7 6)
// 9 page full, 1 page contain 12 info (13 13 13 13 13 13 13 13 13 12)
ASSERT_EQ(max_cnt, MTL(ObDagWarningHistoryManager *)->size());
for (int i = 0; i < 30; ++i) {
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->delete_info(ObBasicDag::KEY_START+i));
}
// every info is 240 bytes, each page contains 7 info
// 69 * 240 > 20480 * 0.8 // after gc, left 34 info (34 * 240 < 20480 * 0.4), means 1 page (7 7 7 7 6)
// every info is 264 bytes, each page contains 13 info
// 129 * 264 > 40960 * 0.8 // after gc, left 62 info (62 * 264 < 40960 * 0.4), means 5 pages (11 13 13 13 12)
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->gc_info());
ASSERT_EQ(34, MTL(ObDagWarningHistoryManager *)->size());
ASSERT_EQ(62, MTL(ObDagWarningHistoryManager *)->size());
}
TEST_F(TestDagWarningHistory, complex_test)
@ -372,7 +376,7 @@ TEST_F(TestDagWarningHistory, complex_test)
ASSERT_EQ(OB_SUCCESS, ret);
int64_t hash_value = ObBasicDag::KEY_START;
const int64_t max_cnt = 20;
const int64_t max_cnt = 39;
for (int i = 0; i < max_cnt; ++i) {
ObComplexDag dag(hash_value++);
dag.init();
@ -380,9 +384,9 @@ TEST_F(TestDagWarningHistory, complex_test)
dag.set_dag_ret(ObBasicDag::DAG_RET_START + i);
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->add_dag_warning_info(&dag));
}
// every info is 240 bytes, each page contains 7 info
// 10 info will be purged , left 2 page (4 6)
ASSERT_EQ(10, MTL(ObDagWarningHistoryManager *)->size());
// every info is 264 bytes, each page contains 13 infos
// 20 info will be purged , left 2 pages (6 13)
ASSERT_EQ(19, MTL(ObDagWarningHistoryManager *)->size());
compaction::ObIDiagnoseInfoMgr::Iterator iterator;
ret = MTL(ObDagWarningHistoryManager *)->open_iter(iterator);
@ -390,8 +394,8 @@ TEST_F(TestDagWarningHistory, complex_test)
ObDagWarningInfo read_info;
char comment[common::OB_DAG_WARNING_INFO_LENGTH];
// the first 10 info have been purged
int i = 10;
// the first 20 info have been purged
int i = 20;
while (OB_SUCC(ret)) {
if (OB_FAIL(iterator.get_next(&read_info, comment, sizeof(comment)))) {
ASSERT_EQ(OB_ITER_END, ret);
@ -408,53 +412,32 @@ TEST_F(TestDagWarningHistory, complex_test)
ASSERT_EQ(OB_SUCCESS, ret);
ret = MTL(ObDagWarningHistoryManager *)->open_iter(iterator2);
ASSERT_EQ(OB_SUCCESS, ret);
i = 10;
i = 20;
ASSERT_EQ(OB_SUCCESS, iterator2.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i++));
ASSERT_EQ(OB_SUCCESS, iterator2.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i++));
i = 20;
ASSERT_EQ(OB_SUCCESS, iterator1.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i++));
ASSERT_EQ(OB_SUCCESS, iterator1.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i++));
i = 10;
ASSERT_EQ(OB_SUCCESS, iterator2.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i++));
ASSERT_EQ(OB_SUCCESS, iterator2.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i++));
ASSERT_EQ(OB_SUCCESS, iterator2.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i++));
i = max_cnt;
{
ObComplexDag dag(hash_value++);
dag.init();
dag.set_dag_status(ObBasicDag::ObDagStatus::DAG_STATUS_ABORT);
dag.set_dag_ret(ObBasicDag::DAG_RET_START + i++);
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->add_dag_warning_info(&dag));
ASSERT_EQ(11, MTL(ObDagWarningHistoryManager *)->size());
}
{
ObComplexDag dag(hash_value++);
dag.init();
dag.set_dag_status(ObBasicDag::ObDagStatus::DAG_STATUS_ABORT);
dag.set_dag_ret(ObBasicDag::DAG_RET_START + i++);
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->add_dag_warning_info(&dag));
ASSERT_EQ(2, MTL(ObDagWarningHistoryManager *)->size());
}
// let the iterator1 in iter_end
int j = 20;
while (OB_SUCC(ret)) {
if (OB_FAIL(iterator1.get_next(&read_info, comment, sizeof(comment)))) {
ASSERT_EQ(OB_ITER_END, ret);
} else {
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + j));
++j;
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + i));
++i;
}
}
// before set_max (1 1), after set_max (1)
// before set_max (6 13), after set_max (6)
ret = MTL(ObDagWarningHistoryManager *)->set_max(INFO_PAGE_SIZE);
ASSERT_EQ(OB_SUCCESS, ret);
ASSERT_EQ(1, MTL(ObDagWarningHistoryManager *)->size());
ASSERT_EQ(6, MTL(ObDagWarningHistoryManager *)->size());
{
ObComplexDag dag(hash_value++);
@ -462,12 +445,12 @@ TEST_F(TestDagWarningHistory, complex_test)
dag.set_dag_status(ObBasicDag::ObDagStatus::DAG_STATUS_ABORT);
dag.set_dag_ret(ObBasicDag::DAG_RET_START + i++);
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->add_dag_warning_info(&dag));
ASSERT_EQ(2, MTL(ObDagWarningHistoryManager *)->size());
ASSERT_EQ(1, MTL(ObDagWarningHistoryManager *)->size());
}
ASSERT_EQ(OB_ITER_END, iterator1.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(OB_SUCCESS, iterator2.get_next(&read_info, comment, sizeof(comment)));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + 21));
ASSERT_EQ(TRUE, read_info.dag_ret_ == (ObBasicDag::DAG_RET_START + max_cnt));
// test purge cuz add when there are some deleted info on list
ASSERT_EQ(OB_SUCCESS, MTL(ObDagWarningHistoryManager *)->delete_info(hash_value-1));
@ -485,10 +468,10 @@ TEST_F(TestDagWarningHistory, complex_test)
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
system("rm -f test_dag_warning_history.log*");
OB_LOGGER.set_file_name("test_dag_warning_history.log");
CLOG_LOG(INFO, "begin unittest: test_dag_warning_history");
oceanbase::common::ObLogger::get_logger().set_log_level("DEBUG");
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}