[CP] rollback fix heap table column array
This commit is contained in:
parent
6292ffde8c
commit
45667e8c2d
@ -1417,7 +1417,6 @@ int ObBasicTabletMergeCtx::get_convert_compaction_info()
|
||||
ObStorageSchema *schema_for_merge = nullptr;
|
||||
ObUpdateCSReplicaSchemaParam param;
|
||||
bool generate_cs_replica_cg_array = false;
|
||||
bool is_heap_table_out_of_order = false;
|
||||
|
||||
if (OB_FAIL(OB_UNLIKELY(EN_COMPACTION_DISABLE_CONVERT_CO))) {
|
||||
LOG_INFO("EN_COMPACTION_DISABLE_CONVERT_CO: disable convert co merge", K(ret));
|
||||
@ -1430,11 +1429,7 @@ int ObBasicTabletMergeCtx::get_convert_compaction_info()
|
||||
LOG_WARN("failed to alloc storage schema", K(ret));
|
||||
} else if (schema_on_tablet->is_column_info_simplified() && OB_FAIL(param.init(*tablet))) {
|
||||
LOG_WARN("failed to init param", K(ret), KPC(tablet));
|
||||
} else if (OB_FAIL(schema_on_tablet->check_is_column_array_out_of_order_for_heap_table(is_heap_table_out_of_order))) {
|
||||
LOG_WARN("failed to check is column array out of order", K(ret), KPC(schema_on_tablet));
|
||||
} else if (FALSE_IT(generate_cs_replica_cg_array = (schema_on_tablet->is_row_store()
|
||||
|| is_heap_table_out_of_order // need re-generate column group array
|
||||
|| schema_on_tablet->is_column_info_simplified()))) {
|
||||
} else if (FALSE_IT(generate_cs_replica_cg_array = (schema_on_tablet->is_row_store() || schema_on_tablet->is_column_info_simplified()))) {
|
||||
// storage schema is column store but simplifed, it should become not simplified before it can be used for merge
|
||||
} else if (OB_FAIL(schema_for_merge->init(mem_ctx_.get_allocator(), *schema_on_tablet,
|
||||
false /*skip_column_info*/, nullptr /*column_group_schema*/, generate_cs_replica_cg_array,
|
||||
|
@ -648,10 +648,6 @@ int ObStorageSchema::deep_copy_column_array(
|
||||
col_schema.destroy(allocator);
|
||||
}
|
||||
}
|
||||
// for heap table, the column array is out of order when tablet firstly created, need sort it.
|
||||
if (FAILEDx(sort_out_of_order_column_array_for_heap_table())) {
|
||||
STORAGE_LOG(WARN, "failed to sort out of order column array for heap table", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -675,36 +671,6 @@ int ObStorageSchema::rebuild_column_array(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStorageSchema::sort_out_of_order_column_array_for_heap_table()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_out_of_order = false;
|
||||
const int64_t rowkey_cnt = rowkey_array_.count();
|
||||
const int64_t column_cnt = column_array_.count();
|
||||
if (!is_heap_table() || is_column_info_simplified()) {
|
||||
} else if (column_cnt < 2 || rowkey_cnt != 1) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "invalid column cnt or rowkey cnt for heap table", K(ret), K(column_cnt), K(rowkey_cnt));
|
||||
} else if (OB_FAIL(check_is_column_array_out_of_order_for_heap_table(is_out_of_order))) {
|
||||
STORAGE_LOG(WARN, "failed to check is column array out of order", K(ret));
|
||||
} else if (is_out_of_order) {
|
||||
// sort rowkey array. heap table only has one rowkey.
|
||||
rowkey_array_[0].column_idx_ = common::OB_APP_MIN_COLUMN_ID;
|
||||
// sort column array
|
||||
ObStorageColumnSchema pk_increment_schema = column_array_[column_cnt - 1];
|
||||
for (int64_t i = column_cnt - 1 ; i > 0; --i) {
|
||||
column_array_[i] = column_array_[i - 1];
|
||||
}
|
||||
column_array_[0] = pk_increment_schema;
|
||||
// sort skip idx attr array
|
||||
for (int64_t i = 0; i < skip_idx_attr_array_.count(); ++i) {
|
||||
skip_idx_attr_array_[i].col_idx_++;
|
||||
}
|
||||
STORAGE_LOG(INFO, "Finsih sort out of order column array for heap table", K(ret), KPC(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStorageSchema::deep_copy_column_group_array(common::ObIAllocator &allocator, const ObStorageSchema &src_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -1101,10 +1067,6 @@ int ObStorageSchema::deserialize_column_array(
|
||||
column.destroy(allocator);
|
||||
}
|
||||
}
|
||||
// for heap table, the column array is out of order when tablet firstly created, need sort it.
|
||||
if (FAILEDx(sort_out_of_order_column_array_for_heap_table())) {
|
||||
STORAGE_LOG(WARN, "failed to sort out of order column array for heap table", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1452,22 +1414,6 @@ bool ObStorageSchema::is_cg_array_generated_in_cs_replica() const
|
||||
return bret;
|
||||
}
|
||||
|
||||
int ObStorageSchema::check_is_column_array_out_of_order_for_heap_table(bool &is_out_of_order) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_out_of_order = false;
|
||||
const int64_t column_cnt = column_array_.count();
|
||||
if (!is_heap_table() || is_column_info_simplified()) {
|
||||
} else if (column_cnt <= 1) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "invalid count of column array", KPC(this));
|
||||
} else if (column_array_[column_cnt - 1].is_rowkey_column()) {
|
||||
is_out_of_order = true; // the __pk_increment column should be the first column of heap table
|
||||
STORAGE_LOG(INFO, "find a out of order heap table", K(ret), KPC(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStorageSchema::deserialize_column_group_array(ObIAllocator &allocator,
|
||||
const char *buf,
|
||||
const int64_t data_len,
|
||||
@ -1691,10 +1637,6 @@ int ObStorageSchema::generate_column_array(const ObTableSchema &input_schema)
|
||||
}
|
||||
}
|
||||
|
||||
// for heap table, the column array is out of order when tablet firstly created, need sort it.
|
||||
if (FAILEDx(sort_out_of_order_column_array_for_heap_table())) {
|
||||
STORAGE_LOG(WARN, "failed to sort out of order column array for heap table", K(ret));
|
||||
}
|
||||
if (tmp_map.created()) {
|
||||
tmp_map.destroy();
|
||||
}
|
||||
|
@ -214,7 +214,6 @@ public:
|
||||
common::ObIAllocator &allocator,
|
||||
const ObStorageSchema &src_schema,
|
||||
const ObUpdateCSReplicaSchemaParam &update_param);
|
||||
int sort_out_of_order_column_array_for_heap_table();
|
||||
int deep_copy_column_group_array(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObStorageSchema &src_schema);
|
||||
@ -317,12 +316,6 @@ public:
|
||||
const uint64_t &column_id,
|
||||
const int32_t &column_idx,
|
||||
int32_t &cg_idx) const;
|
||||
/*
|
||||
* For heap table (no pk, only has __pk_increment), the column array is out of order when tablet firstly created.
|
||||
* The the __pk_increment column is in the LAST of column array in ObCreateTableSchema,
|
||||
* but in the FIRST in ObTableSchema read by schema guard from inner table.
|
||||
*/
|
||||
int check_is_column_array_out_of_order_for_heap_table(bool &is_out_of_order) const;
|
||||
bool is_cg_array_generated_in_cs_replica() const;
|
||||
// Use this comparison function to determine which schema has been updated later
|
||||
// true: input_schema is newer
|
||||
@ -336,7 +329,6 @@ public:
|
||||
inline bool is_aux_lob_meta_table() const { return share::schema::is_aux_lob_meta_table(table_type_); }
|
||||
inline bool is_aux_lob_piece_table() const { return share::schema::is_aux_lob_piece_table(table_type_); }
|
||||
OB_INLINE bool is_user_hidden_table() const { return share::schema::TABLE_STATE_IS_HIDDEN_MASK & table_mode_.state_flag_; }
|
||||
OB_INLINE bool is_heap_table() const { return share::schema::TOM_HEAP_ORGANIZED == (enum share::schema::ObTableOrganizationMode)table_mode_.organization_mode_; }
|
||||
OB_INLINE bool is_cs_replica_compat() const { return is_cs_replica_compat_; }
|
||||
|
||||
VIRTUAL_TO_STRING_KV(KP(this), K_(storage_schema_version), K_(version),
|
||||
|
@ -35,8 +35,6 @@
|
||||
#include "storage/ob_storage_schema.h"
|
||||
#include "share/scn.h"
|
||||
#include "storage/test_schema_prepare.h"
|
||||
#include "storage/test_tablet_helper.h"
|
||||
#include "storage/high_availability/ob_storage_ha_tablet_builder.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -94,25 +92,6 @@ public:
|
||||
const int64_t max_merged_trans_version,
|
||||
const int64_t upper_trans_version,
|
||||
ObTableHandleV2 &table_handle);
|
||||
static int mock_column_sstable(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObITable::TableType &type,
|
||||
const ObCOSSTableBaseType &co_base_type,
|
||||
const int64_t base_version,
|
||||
const int64_t snapshot_version,
|
||||
const int64_t max_merged_trans_version,
|
||||
const int64_t upper_trans_version,
|
||||
const int64_t column_group_cnt,
|
||||
ObTableHandleV2 &table_handle);
|
||||
static int mock_co_sstable(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObCOSSTableBaseType &co_base_type,
|
||||
const int64_t base_version,
|
||||
const int64_t snapshot_version,
|
||||
const int64_t max_merged_trans_version,
|
||||
const int64_t upper_trans_version,
|
||||
const int64_t column_group_cnt,
|
||||
ObTableHandleV2 &table_handle);
|
||||
static int mock_sstable_meta(
|
||||
const int64_t row_count,
|
||||
ObTableHandleV2 &table_handle);
|
||||
@ -272,7 +251,7 @@ void TestCompactionPolicy::generate_table_key(
|
||||
table_key.reset();
|
||||
table_key.tablet_id_ = TEST_TABLET_ID;
|
||||
table_key.table_type_ = type;
|
||||
if (ObITable::is_major_sstable(type)) {
|
||||
if (type == ObITable::TableType::MAJOR_SSTABLE) {
|
||||
table_key.version_range_.base_version_ = start_scn;
|
||||
table_key.version_range_.snapshot_version_ = end_scn;
|
||||
} else {
|
||||
@ -336,121 +315,6 @@ int TestCompactionPolicy::mock_sstable(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TestCompactionPolicy::mock_column_sstable(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObITable::TableType &type,
|
||||
const ObCOSSTableBaseType &co_base_type,
|
||||
const int64_t base_version,
|
||||
const int64_t snapshot_version,
|
||||
const int64_t max_merged_trans_version,
|
||||
const int64_t upper_trans_version,
|
||||
const int64_t column_group_cnt,
|
||||
ObTableHandleV2 &table_handle)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
ObTableSchema table_schema;
|
||||
TestSchemaUtils::prepare_data_schema(table_schema);
|
||||
|
||||
ObITable::TableKey table_key;
|
||||
generate_table_key(type, base_version, snapshot_version, table_key);
|
||||
|
||||
ObTabletID tablet_id;
|
||||
tablet_id = TEST_TABLET_ID;
|
||||
ObTabletCreateSSTableParam param;
|
||||
ObStorageSchema storage_schema;
|
||||
ObSSTable *sstable = nullptr;
|
||||
|
||||
if (OB_FAIL(storage_schema.init(allocator, table_schema, lib::Worker::CompatMode::MYSQL))) {
|
||||
LOG_WARN("failed to init storage schema", K(ret));
|
||||
} else if (OB_FAIL(ObTabletCreateDeleteHelper::build_create_sstable_param(storage_schema, tablet_id, 100, param))) {
|
||||
LOG_WARN("failed to build create sstable param", K(ret), K(table_key));
|
||||
} else {
|
||||
param.table_key_ = table_key;
|
||||
param.max_merged_trans_version_ = max_merged_trans_version;
|
||||
param.filled_tx_scn_ = table_key.get_end_scn();
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (ObITable::TableType::COLUMN_ORIENTED_SSTABLE == type) {
|
||||
param.column_group_cnt_ = column_group_cnt;
|
||||
param.co_base_type_ = co_base_type;
|
||||
if (OB_FAIL(ObTabletCreateDeleteHelper::create_sstable<ObCOSSTableV2>(param, allocator, table_handle))) {
|
||||
LOG_WARN("failed to create co sstable", K(ret), K(param));
|
||||
}
|
||||
} else if (OB_FAIL(ObTabletCreateDeleteHelper::create_sstable(param, allocator, table_handle))) {
|
||||
LOG_WARN("failed to create sstable", K(ret), K(param));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(table_handle.get_sstable(sstable))) {
|
||||
LOG_WARN("failed to get table", K(ret), K(table_handle));
|
||||
} else if (OB_ISNULL(sstable)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get sstable", K(ret), K(table_handle));
|
||||
} else {
|
||||
sstable->meta_->basic_meta_.max_merged_trans_version_ = max_merged_trans_version;
|
||||
sstable->meta_->basic_meta_.upper_trans_version_ = upper_trans_version;
|
||||
sstable->meta_cache_.max_merged_trans_version_ = max_merged_trans_version;
|
||||
sstable->meta_cache_.upper_trans_version_ = upper_trans_version;
|
||||
sstable->meta_cache_.nested_size_ = 0;
|
||||
sstable->meta_cache_.nested_offset_ = 0;
|
||||
LOG_INFO("Finish mock column sstable", K(ret), KPC(sstable));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TestCompactionPolicy::mock_co_sstable(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObCOSSTableBaseType &co_base_type,
|
||||
const int64_t base_version,
|
||||
const int64_t snapshot_version,
|
||||
const int64_t max_merged_trans_version,
|
||||
const int64_t upper_trans_version,
|
||||
const int64_t column_group_cnt,
|
||||
ObTableHandleV2 &table_handle)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObITable *co_table = nullptr;
|
||||
ObCOSSTableV2 *co_sstable = nullptr;
|
||||
ObSEArray<ObTableHandleV2, 4> cg_handles;
|
||||
ObSEArray<ObITable *, 4> cg_sstables;
|
||||
if (OB_FAIL(TestCompactionPolicy::mock_column_sstable(allocator, ObITable::COLUMN_ORIENTED_SSTABLE, ObCOSSTableBaseType::ROWKEY_CG_TYPE,
|
||||
base_version, snapshot_version, max_merged_trans_version, upper_trans_version, column_group_cnt, table_handle))) {
|
||||
LOG_WARN("failed to mock co sstable", K(ret));
|
||||
} else if (OB_ISNULL(co_table = table_handle.get_table()) || !co_table->is_co_sstable() || OB_ISNULL(co_sstable = static_cast<ObCOSSTableV2 *>(co_table))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get co sstable", K(ret), KPC(co_table));
|
||||
} else {
|
||||
const int64_t normal_cg_cnt = column_group_cnt - 1;
|
||||
for (int64_t idx = 0; OB_SUCC(ret) && idx < normal_cg_cnt; idx++) {
|
||||
ObITable *cg_sstable = nullptr;
|
||||
if (OB_FAIL(cg_handles.push_back(ObTableHandleV2()))) {
|
||||
LOG_WARN("failed to push back cg handle", K(ret));
|
||||
} else if (OB_FAIL(TestCompactionPolicy::mock_column_sstable(allocator, ObITable::NORMAL_COLUMN_GROUP_SSTABLE, ObCOSSTableBaseType::MAX_TYPE,
|
||||
base_version, snapshot_version, max_merged_trans_version, upper_trans_version, column_group_cnt, cg_handles[idx]))) {
|
||||
LOG_WARN("failed to mock cg sstable", K(ret));
|
||||
} else if (OB_ISNULL(cg_sstable = cg_handles[idx].get_table()) || !cg_sstable->is_cg_sstable()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get cg sstable", K(ret), K(cg_handles[idx]), KPC(cg_sstable));
|
||||
} else if (FALSE_IT(cg_sstable->key_.column_group_idx_ = idx + 1)) {
|
||||
} else if (OB_FAIL(cg_sstables.push_back(cg_sstable))) {
|
||||
LOG_WARN("failed to push back cg sstable", K(ret), KP(cg_sstable));
|
||||
} else {
|
||||
LOG_INFO("Finish mock cg sstable", K(ret), KPC(cg_sstable));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(co_sstable->fill_cg_sstables(cg_sstables))) {
|
||||
LOG_WARN("failed to fill cg sstables", K(ret), KPC(co_sstable), K(cg_sstables));
|
||||
} else {
|
||||
LOG_INFO("Finish mock co sstable", K(ret), KPC(co_sstable));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TestCompactionPolicy::mock_sstable_meta(
|
||||
const int64_t row_count,
|
||||
ObTableHandleV2 &table_handle)
|
||||
@ -1405,166 +1269,6 @@ TEST_F(TestCompactionPolicy, check_minor_merge_policy_with_large_minor3)
|
||||
ASSERT_EQ(350, result.scn_range_.end_scn_.get_val_for_tx());
|
||||
}
|
||||
|
||||
TEST_F(TestCompactionPolicy, test_co_convert_replace_old_major)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const char *key_data =
|
||||
"table_type start_scn end_scn max_ver upper_ver\n"
|
||||
"10 0 1 1 1 \n"
|
||||
"11 1 80 80 120 \n"
|
||||
"11 80 150 150 500 \n"
|
||||
"0 150 200 180 180 \n"
|
||||
"0 200 0 0 0 \n";
|
||||
|
||||
ret = prepare_tablet(key_data, 150, 150);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletTableStore &table_store = *tablet_handle_.get_obj()->table_store_addr_.get_ptr();
|
||||
LOG_INFO("[CS-Replica] show table store", K(ret), K(table_store), K(ObPrintTableStore(table_store)));
|
||||
|
||||
ObSEArray<ObITable *, 4> major_tables;
|
||||
ObSEArray<ObITable *, 4> new_sstables;
|
||||
ObTableHandleV2 co_table_handle;
|
||||
ret = mock_co_sstable(allocator_, ObCOSSTableBaseType::ROWKEY_CG_TYPE, 0 /*base_version*/, 1 /*snapshot_version*/,
|
||||
1 /*max_merged_trans_version*/, 1 /*upper_trans_version*/, 4 /*column_group_cnt*/, co_table_handle);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObITable *co_sstable = co_table_handle.get_table();
|
||||
ASSERT_NE(nullptr, co_sstable);
|
||||
ASSERT_EQ(OB_SUCCESS, new_sstables.push_back(co_sstable));
|
||||
ASSERT_EQ(OB_SUCCESS, table_store.major_tables_.replace_twin_majors_and_build_new(new_sstables, major_tables));
|
||||
}
|
||||
|
||||
TEST_F(TestCompactionPolicy, test_co_convert_replace_old_major_rebuild)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const char *key_data =
|
||||
"table_type start_scn end_scn max_ver upper_ver\n"
|
||||
"11 1 80 80 120 \n"
|
||||
"11 80 150 150 500 \n"
|
||||
"0 150 200 180 180 \n"
|
||||
"0 200 0 0 0 \n";
|
||||
|
||||
ret = prepare_tablet(key_data, 150, 150);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletTableStore &table_store = *tablet_handle_.get_obj()->table_store_addr_.get_ptr();
|
||||
LOG_INFO("[CS-Replica] show table store", K(ret), K(table_store), K(ObPrintTableStore(table_store)));
|
||||
|
||||
ObSEArray<ObITable *, 4> hybrid_major_tables;
|
||||
ObTableHandleV2 co_table_handle0;
|
||||
ret = mock_co_sstable(allocator_, ObCOSSTableBaseType::ROWKEY_CG_TYPE, 0 /*base_version*/, 1 /*snapshot_version*/,
|
||||
1 /*max_merged_trans_version*/, 1 /*upper_trans_version*/, 4 /*column_group_cnt*/, co_table_handle0);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, co_table_handle0.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(co_table_handle0.get_table()));
|
||||
|
||||
ObTableHandleV2 table_handle0;
|
||||
ret = mock_sstable(allocator_, ObITable::MAJOR_SSTABLE, 0 /*base_version*/, 100 /*snapshot_version*/,
|
||||
100 /*max_merged_trans_version*/, 100 /*upper_trans_version*/, table_handle0);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, table_handle0.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(table_handle0.get_table()));
|
||||
|
||||
ObTableHandleV2 table_handle1;
|
||||
ret = mock_sstable(allocator_, ObITable::MAJOR_SSTABLE, 0 /*base_version*/, 200 /*snapshot_version*/,
|
||||
200 /*max_merged_trans_version*/, 200 /*upper_trans_version*/, table_handle1);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, table_handle1.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(table_handle1.get_table()));
|
||||
|
||||
ObSSTableArray mock_old_table_store_majors;
|
||||
ASSERT_EQ(OB_SUCCESS, mock_old_table_store_majors.init(allocator_, hybrid_major_tables, 0));
|
||||
|
||||
ObSEArray<ObITable *, 4> major_tables;
|
||||
ObSEArray<ObITable *, 4> new_sstables;
|
||||
ObTableHandleV2 co_table_handle;
|
||||
ret = mock_co_sstable(allocator_, ObCOSSTableBaseType::ROWKEY_CG_TYPE, 0 /*base_version*/, 200 /*snapshot_version*/,
|
||||
200 /*max_merged_trans_version*/, 200 /*upper_trans_version*/, 4 /*column_group_cnt*/, co_table_handle);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObITable *co_sstable = co_table_handle.get_table();
|
||||
ASSERT_NE(nullptr, co_sstable);
|
||||
ASSERT_EQ(OB_SUCCESS, new_sstables.push_back(co_sstable));
|
||||
ASSERT_EQ(OB_SUCCESS, mock_old_table_store_majors.replace_twin_majors_and_build_new(new_sstables, major_tables));
|
||||
table_store.major_tables_.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, table_store.major_tables_.init(allocator_, major_tables, 0 /*start_pos*/));
|
||||
LOG_INFO("[CS-Replica] after replace co major", K(ret), K(table_store), K(ObPrintTableStore(table_store)));
|
||||
}
|
||||
|
||||
TEST_F(TestCompactionPolicy, test_build_tablet_for_hybrid_store)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObITable *, 4> hybrid_major_tables;
|
||||
ObTablesHandleArray hybrid_major_handle_array;
|
||||
ObTableHandleV2 co_table_handle0;
|
||||
ret = mock_co_sstable(allocator_, ObCOSSTableBaseType::ROWKEY_CG_TYPE, 0 /*base_version*/, 1 /*snapshot_version*/,
|
||||
1 /*max_merged_trans_version*/, 1 /*upper_trans_version*/, 4 /*column_group_cnt*/, co_table_handle0);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, co_table_handle0.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(co_table_handle0.get_table()));
|
||||
|
||||
ObTableHandleV2 table_handle0;
|
||||
ret = mock_sstable(allocator_, ObITable::MAJOR_SSTABLE, 0 /*base_version*/, 100 /*snapshot_version*/,
|
||||
100 /*max_merged_trans_version*/, 100 /*upper_trans_version*/, table_handle0);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, table_handle0.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(table_handle0.get_table()));
|
||||
|
||||
ObTableHandleV2 table_handle1;
|
||||
ret = mock_sstable(allocator_, ObITable::MAJOR_SSTABLE, 0 /*base_version*/, 200 /*snapshot_version*/,
|
||||
200 /*max_merged_trans_version*/, 200 /*upper_trans_version*/, table_handle1);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, table_handle1.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(table_handle1.get_table()));
|
||||
|
||||
ObTableHandleV2 co_table_handle1;
|
||||
ret = mock_co_sstable(allocator_, ObCOSSTableBaseType::ROWKEY_CG_TYPE, 0 /*base_version*/, 300 /*snapshot_version*/,
|
||||
300 /*max_merged_trans_version*/, 300 /*upper_trans_version*/, 4 /*column_group_cnt*/, co_table_handle1);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, co_table_handle1.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(co_table_handle1.get_table()));
|
||||
|
||||
ObTableHandleV2 table_handle2;
|
||||
ret = mock_sstable(allocator_, ObITable::MAJOR_SSTABLE, 0 /*base_version*/, 400 /*snapshot_version*/,
|
||||
400 /*max_merged_trans_version*/, 400 /*upper_trans_version*/, table_handle2);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_NE(nullptr, table_handle2.get_table());
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_tables.push_back(table_handle2.get_table()));
|
||||
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_handle_array.add_table(co_table_handle0));
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_handle_array.add_table(table_handle0));
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_handle_array.add_table(table_handle1));
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_handle_array.add_table(co_table_handle1));
|
||||
ASSERT_EQ(OB_SUCCESS, hybrid_major_handle_array.add_table(table_handle2));
|
||||
|
||||
ObLSID ls_id = ObLSID(TEST_LS_ID);
|
||||
ObTabletID tablet_id = ObTabletID(TEST_TABLET_ID + 1);
|
||||
ObLSHandle ls_handle;
|
||||
ASSERT_NE(nullptr, MTL(ObLSService *));
|
||||
ASSERT_EQ(OB_SUCCESS, MTL(ObLSService *)->get_ls(ls_id, ls_handle, ObLSGetMod::STORAGE_MOD));
|
||||
ASSERT_TRUE(ls_handle.is_valid());
|
||||
ObLS *ls = ls_handle.get_ls();
|
||||
ASSERT_NE(nullptr, ls);
|
||||
|
||||
ObTableSchema table_schema;
|
||||
TestSchemaUtils::prepare_data_schema(table_schema);
|
||||
ObStorageSchema storage_schema;
|
||||
ASSERT_EQ(OB_SUCCESS, storage_schema.init(allocator_, table_schema, lib::Worker::CompatMode::MYSQL));
|
||||
ASSERT_EQ(OB_SUCCESS, TestTabletHelper::create_tablet(ls_handle, tablet_id, table_schema, allocator_));
|
||||
|
||||
ObStorageHATabletBuilderUtil::BatchBuildTabletTablesExtraParam extra_batch_param;
|
||||
ret = ObStorageHATabletBuilderUtil::build_tablet_for_row_store_(ls, tablet_id, hybrid_major_handle_array, storage_schema, extra_batch_param);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
ObTabletHandle tablet_handle;
|
||||
ASSERT_EQ(OB_SUCCESS, ls->get_tablet(tablet_id, tablet_handle));
|
||||
ASSERT_TRUE(tablet_handle.is_valid());
|
||||
ObTablet *tablet = tablet_handle.get_obj();
|
||||
ASSERT_NE(nullptr, tablet);
|
||||
ObTabletMemberWrapper<ObTabletTableStore> table_store_wrapper;
|
||||
ASSERT_EQ(OB_SUCCESS, tablet->fetch_table_store(table_store_wrapper));
|
||||
ASSERT_TRUE(table_store_wrapper.is_valid());
|
||||
const ObTabletTableStore &table_store = *table_store_wrapper.get_member();
|
||||
LOG_INFO("[CS-Replica] show hybrid table store", K(ret), K(table_store), K(ObPrintTableStore(table_store)));
|
||||
}
|
||||
|
||||
} //unittest
|
||||
} //oceanbase
|
||||
|
||||
|
@ -39,10 +39,6 @@ public:
|
||||
virtual void TearDown() override;
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
static void generate_heap_table_schema(
|
||||
ObIArray<ColumnType> &column_types,
|
||||
bool is_out_of_order,
|
||||
share::schema::ObTableSchema &table_schema);
|
||||
static const int64_t tenant_id = 1;
|
||||
common::ObArenaAllocator allocator_;
|
||||
ObTenantBase tenant_base_;
|
||||
@ -67,96 +63,6 @@ void TestStorageSchema::TearDownTestCase()
|
||||
MockTenantModuleEnv::get_instance().destroy();
|
||||
}
|
||||
|
||||
void TestStorageSchema::generate_heap_table_schema(
|
||||
ObIArray<ColumnType> &column_types,
|
||||
bool is_out_of_order,
|
||||
share::schema::ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const uint64_t tenant_id = 1;
|
||||
const uint64_t table_id = 7777;
|
||||
|
||||
table_schema.reset();
|
||||
ret = table_schema.set_table_name("test_heap_table_storage_schema");
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
table_schema.set_table_organization_mode(share::schema::ObTableOrganizationMode::TOM_HEAP_ORGANIZED);
|
||||
table_schema.set_tenant_id(tenant_id);
|
||||
table_schema.set_tablegroup_id(1);
|
||||
table_schema.set_database_id(1);
|
||||
table_schema.set_table_id(table_id);
|
||||
table_schema.set_rowkey_column_num(1);
|
||||
table_schema.set_max_used_column_id(common::OB_APP_MIN_COLUMN_ID + column_types.count());
|
||||
table_schema.set_block_size(16 * 1024);
|
||||
table_schema.set_compress_func_name("none");
|
||||
table_schema.set_row_store_type(FLAT_ROW_STORE);
|
||||
table_schema.set_pctfree(10);
|
||||
table_schema.set_schema_version(100);
|
||||
|
||||
share::schema::ObColumnSchemaV2 pk_column;
|
||||
pk_column.set_table_id(table_id);
|
||||
pk_column.set_column_id(common::OB_HIDDEN_PK_INCREMENT_COLUMN_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, pk_column.set_column_name(common::OB_HIDDEN_PK_INCREMENT_COLUMN_NAME));
|
||||
pk_column.set_rowkey_position(1);
|
||||
pk_column.set_data_type(ObUInt64Type);
|
||||
pk_column.set_collation_type(CS_TYPE_UTF8MB4_GENERAL_CI);
|
||||
pk_column.set_data_length(10);
|
||||
pk_column.set_is_hidden(true);
|
||||
|
||||
if (!is_out_of_order) {
|
||||
COMMON_LOG(INFO, "add pk column", K(pk_column));
|
||||
ASSERT_EQ(OB_SUCCESS, table_schema.add_column(pk_column));
|
||||
}
|
||||
|
||||
for (int64_t idx = 0; idx < column_types.count(); ++idx) {
|
||||
share::schema::ObColumnSchemaV2 column;
|
||||
const ColumnType &col_type = column_types.at(idx);
|
||||
const int64_t column_id = common::OB_APP_MIN_COLUMN_ID + idx;
|
||||
char name[OB_MAX_FILE_NAME_LENGTH];
|
||||
memset(name, 0, sizeof(name));
|
||||
sprintf(name, "col%020ld", idx);
|
||||
column.set_table_id(table_id);
|
||||
column.set_column_id(column_id);
|
||||
ASSERT_EQ(OB_SUCCESS, column.set_column_name(name));
|
||||
column.set_rowkey_position(0);
|
||||
column.set_data_type(column_types.at(idx));
|
||||
column.set_collation_type(CS_TYPE_UTF8MB4_GENERAL_CI);
|
||||
column.set_data_length(10);
|
||||
column.set_is_hidden(false);
|
||||
ObSkipIndexColumnAttr skip_index_column_attr;
|
||||
skip_index_column_attr.reset();
|
||||
if ((idx % 3) == 0) {
|
||||
skip_index_column_attr.set_sum();
|
||||
} else if ((idx % 3) == 1) {
|
||||
skip_index_column_attr.set_min_max();
|
||||
}
|
||||
column.set_skip_index_attr(skip_index_column_attr.get_packed_value());
|
||||
ObObj default_value;
|
||||
if (ObIntType == col_type) {
|
||||
default_value.set_int(100);
|
||||
column.set_orig_default_value(default_value);
|
||||
} else if (ObVarcharType == col_type) {
|
||||
default_value.set_varchar("default_value");
|
||||
default_value.set_collation_type(ObCharset::get_system_collation());
|
||||
default_value.set_collation_level(CS_LEVEL_IMPLICIT);
|
||||
column.set_orig_default_value(default_value);
|
||||
} else if (ObTimeType == col_type) {
|
||||
default_value.set_time(10);
|
||||
column.set_orig_default_value(default_value);
|
||||
} else if (ObDoubleType == col_type) {
|
||||
default_value.set_double(60.0);
|
||||
column.set_orig_default_value(default_value);
|
||||
}
|
||||
COMMON_LOG(INFO, "add column", K(idx), K(column));
|
||||
ASSERT_EQ(OB_SUCCESS, table_schema.add_column(column));
|
||||
}
|
||||
|
||||
if (is_out_of_order) {
|
||||
COMMON_LOG(INFO, "add pk column", K(pk_column));
|
||||
ASSERT_EQ(OB_SUCCESS, table_schema.add_column(pk_column));
|
||||
}
|
||||
COMMON_LOG(INFO, "Finish generate heap table schema", K(column_types), K(is_out_of_order), K(table_schema));
|
||||
}
|
||||
|
||||
bool TestStorageSchema::judge_storage_schema_equal(ObStorageSchema &schema1, ObStorageSchema &schema2)
|
||||
{
|
||||
bool equal = false;
|
||||
@ -420,48 +326,6 @@ TEST_F(TestStorageSchema, test_update_tablet_store_schema)
|
||||
ObStorageSchemaUtil::free_storage_schema(allocator_, result_storage_schema);
|
||||
}
|
||||
|
||||
TEST_F(TestStorageSchema, test_sort_head_table_column_array_basic)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
share::schema::ObTableSchema table_schema1;
|
||||
share::schema::ObTableSchema table_schema2;
|
||||
ObSEArray<ColumnType, 4> column_types;
|
||||
ASSERT_EQ(OB_SUCCESS, column_types.push_back(ObIntType));
|
||||
ASSERT_EQ(OB_SUCCESS, column_types.push_back(ObVarcharType));
|
||||
ASSERT_EQ(OB_SUCCESS, column_types.push_back(ObTimeType));
|
||||
ASSERT_EQ(OB_SUCCESS, column_types.push_back(ObDoubleType));
|
||||
TestStorageSchema::generate_heap_table_schema(column_types, true /*out_of_order*/, table_schema1);
|
||||
TestStorageSchema::generate_heap_table_schema(column_types, false /*out_of_order*/, table_schema2);
|
||||
|
||||
ObStorageSchema storage_schema1;
|
||||
ObStorageSchema storage_schema2;
|
||||
ASSERT_EQ(OB_SUCCESS, storage_schema1.init(allocator_, table_schema1, lib::Worker::CompatMode::MYSQL));
|
||||
ASSERT_EQ(OB_SUCCESS, storage_schema2.init(allocator_, table_schema2, lib::Worker::CompatMode::MYSQL));
|
||||
COMMON_LOG(INFO, "Finish init storage schema1", K(storage_schema1));
|
||||
COMMON_LOG(INFO, "Finish init storage schema2", K(storage_schema2));
|
||||
|
||||
ASSERT_TRUE(storage_schema1.is_heap_table());
|
||||
ASSERT_TRUE(storage_schema2.is_heap_table());
|
||||
ASSERT_EQ(storage_schema1.rowkey_array_.count(), storage_schema2.rowkey_array_.count());
|
||||
ASSERT_EQ(storage_schema1.column_array_.count(), storage_schema2.column_array_.count());
|
||||
ASSERT_EQ(storage_schema1.skip_idx_attr_array_.count(), storage_schema2.skip_idx_attr_array_.count());
|
||||
|
||||
bool is_out_of_order = false;
|
||||
ASSERT_EQ(OB_SUCCESS, storage_schema1.check_is_column_array_out_of_order_for_heap_table(is_out_of_order));
|
||||
ASSERT_FALSE(is_out_of_order);
|
||||
ASSERT_EQ(OB_SUCCESS, storage_schema2.check_is_column_array_out_of_order_for_heap_table(is_out_of_order));
|
||||
ASSERT_FALSE(is_out_of_order);
|
||||
|
||||
ASSERT_EQ(storage_schema1.rowkey_array_[0].column_idx_, storage_schema2.rowkey_array_[0].column_idx_);
|
||||
for (int64_t idx = 0; idx < storage_schema1.column_array_.count(); idx++) {
|
||||
ASSERT_EQ(storage_schema1.column_array_[idx].get_data_type(), storage_schema2.column_array_[idx].get_data_type());
|
||||
ASSERT_TRUE(storage_schema1.column_array_[idx].get_orig_default_value() == storage_schema2.column_array_[idx].get_orig_default_value());
|
||||
}
|
||||
for (int64_t idx = 0; idx < storage_schema1.skip_idx_attr_array_.count(); idx++) {
|
||||
ASSERT_EQ(storage_schema1.skip_idx_attr_array_[idx].col_idx_, storage_schema2.skip_idx_attr_array_[idx].col_idx_);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace unittest
|
||||
} // namespace oceanbase
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user