[DATA_DICT] fix obcdc exist caused by index_tablet not found in data_dict

This commit is contained in:
SanmuWangZJU
2023-02-21 08:44:56 +00:00
committed by ob-robot
parent 16885fe829
commit ea16d3cd79
2 changed files with 57 additions and 42 deletions

View File

@ -587,7 +587,8 @@ int ObDataDictService::filter_table_(const share::schema::ObTableSchema *table_s
DDLOG(WARN, "invalid table_schema", KR(ret));
} else {
is_filtered =
! (table_schema->is_user_table()
! (table_schema->has_tablet()
|| table_schema->is_user_table()
|| table_schema->is_unique_index()
|| table_schema->is_tmp_table());
}

View File

@ -1071,18 +1071,8 @@ int ObDictTableMeta::build_index_info_(const schema::ObTableSchema &table_schema
int ret = OB_SUCCESS;
const common::ObIndexInfo &index_info = table_schema.get_index_info();
const ObIArray<ObAuxTableMetaInfo> &simple_index_infos = table_schema.get_simple_index_infos();
index_column_count_ = index_info.get_size();
const int64_t alloc_size = sizeof(common::ObIndexColumn) * index_column_count_;
if (OB_ISNULL(allocator_)) {
ret = OB_ERR_UNEXPECTED;
DDLOG(WARN, "invalid allocator_", KR(ret));
} else if (index_column_count_ <= 0) {
DDLOG(TRACE, "not found index_cols_, skip", KPC(this));
} else if (OB_ISNULL(index_cols_ = static_cast<ObIndexColumn*>(allocator_->alloc(alloc_size)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
DDLOG(WARN, "alloc for index_cols_ failed", KR(ret), K(alloc_size), KPC(this));
} else {
if (table_schema.is_user_table()) {
// build index_table_id_arr
for (int i = 0; OB_SUCC(ret) &&i < simple_index_infos.count(); i++) {
ObAuxTableMetaInfo index_table_info;
@ -1095,21 +1085,38 @@ int ObDictTableMeta::build_index_info_(const schema::ObTableSchema &table_schema
KR(ret), K(i), K(simple_index_infos), K_(unique_index_tid_arr), KPC(this));
}
}
} else if (table_schema.is_unique_index()) {
// only build index column info for unique index table, cause OBCDC only use unique_index info.
index_column_count_ = index_info.get_size();
const int64_t alloc_size = sizeof(common::ObIndexColumn) * index_column_count_;
// build index_columns
for (int i = 0; OB_SUCC(ret) && i < index_column_count_; i++) {
ObIndexColumn *idx_col = new (index_cols_ + i) ObIndexColumn();
ObIndexColumn tmp_idx_col;
if (OB_ISNULL(allocator_)) {
ret = OB_ERR_UNEXPECTED;
DDLOG(WARN, "invalid allocator_", KR(ret));
} else if (index_column_count_ <= 0) {
DDLOG(TRACE, "not found index_cols_, skip", KPC(this));
} else if (OB_ISNULL(index_cols_ = static_cast<ObIndexColumn*>(allocator_->alloc(alloc_size)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
DDLOG(WARN, "alloc for index_cols_ failed", KR(ret), K(alloc_size), KPC(this));
} else {
// build index_columns
for (int i = 0; OB_SUCC(ret) && i < index_column_count_; i++) {
ObIndexColumn *idx_col = new (index_cols_ + i) ObIndexColumn();
ObIndexColumn tmp_idx_col;
if (OB_FAIL(index_info.get_column(i, tmp_idx_col))) {
DDLOG(WARN, "get_index_column from ObIndexInfo failed", KR(ret), K(index_info), K(i), KPC(this));
} else if (OB_ISNULL(idx_col)) {
ret = OB_INVALID_DATA;
DDLOG(WARN, "expect valid index_column", KR(ret), K(index_info), K(i), KPC(this));
} else {
*idx_col = tmp_idx_col;
if (OB_FAIL(index_info.get_column(i, tmp_idx_col))) {
DDLOG(WARN, "get_index_column from ObIndexInfo failed", KR(ret), K(index_info), K(i), KPC(this));
} else if (OB_ISNULL(idx_col)) {
ret = OB_INVALID_DATA;
DDLOG(WARN, "expect valid index_column", KR(ret), K(index_info), K(i), KPC(this));
} else {
*idx_col = tmp_idx_col;
}
}
}
} else {
// ignore index info of other table type
// and other type of table exclude user table and unique index table
}
return ret;
@ -1159,27 +1166,32 @@ int ObDictTableMeta::build_index_info_(const ObDictTableMeta &src_table_meta)
int ObDictTableMeta::build_rowkey_info_(const schema::ObTableSchema &table_schema)
{
int ret = OB_SUCCESS;
const common::ObRowkeyInfo &rowkey_info = table_schema.get_rowkey_info();
rowkey_column_count_ = rowkey_info.get_size();
const int64_t alloc_size = sizeof(common::ObRowkeyColumn) * rowkey_column_count_;
if (rowkey_column_count_ <= 0) {
DDLOG(TRACE, "not found rowkey cols, skip", KPC(this));
} else if (OB_ISNULL(rowkey_cols_ = static_cast<ObRowkeyColumn*>(allocator_->alloc(alloc_size)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
DDLOG(WARN, "alloc for rowkey_cols_ failed", KR(ret), K(alloc_size), KPC(this));
if (!table_schema.is_user_table()) {
// only record rowkey column info for user table.
} else {
for (int i = 0; OB_SUCC(ret) && i < rowkey_column_count_; i++) {
ObRowkeyColumn *rowkey_col = new (rowkey_cols_ + i) ObRowkeyColumn();
ObRowkeyColumn tmp_rowkey_col;
const common::ObRowkeyInfo &rowkey_info = table_schema.get_rowkey_info();
rowkey_column_count_ = rowkey_info.get_size();
const int64_t alloc_size = sizeof(common::ObRowkeyColumn) * rowkey_column_count_;
if (OB_FAIL(rowkey_info.get_column(i, tmp_rowkey_col))) {
DDLOG(WARN, "get_rowkey_column from ObRowkeyInfo failed", KR(ret), K(rowkey_info), K(i), KPC(this));
} else if (OB_ISNULL(rowkey_col)) {
ret = OB_INVALID_DATA;
DDLOG(WARN, "expect valid rowkey_column", KR(ret), K(rowkey_info), K(i), KPC(this));
} else {
*rowkey_col = tmp_rowkey_col;
if (rowkey_column_count_ <= 0) {
DDLOG(TRACE, "not found rowkey cols, skip", KPC(this));
} else if (OB_ISNULL(rowkey_cols_ = static_cast<ObRowkeyColumn*>(allocator_->alloc(alloc_size)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
DDLOG(WARN, "alloc for rowkey_cols_ failed", KR(ret), K(alloc_size), KPC(this));
} else {
for (int i = 0; OB_SUCC(ret) && i < rowkey_column_count_; i++) {
ObRowkeyColumn *rowkey_col = new (rowkey_cols_ + i) ObRowkeyColumn();
ObRowkeyColumn tmp_rowkey_col;
if (OB_FAIL(rowkey_info.get_column(i, tmp_rowkey_col))) {
DDLOG(WARN, "get_rowkey_column from ObRowkeyInfo failed", KR(ret), K(rowkey_info), K(i), KPC(this));
} else if (OB_ISNULL(rowkey_col)) {
ret = OB_INVALID_DATA;
DDLOG(WARN, "expect valid rowkey_column", KR(ret), K(rowkey_info), K(i), KPC(this));
} else {
*rowkey_col = tmp_rowkey_col;
}
}
}
}
@ -1224,7 +1236,9 @@ int ObDictTableMeta::build_column_info_(const schema::ObTableSchema &table_schem
int ret = OB_SUCCESS;
common::ObArray<share::schema::ObColDesc> column_ids;
if (OB_ISNULL(allocator_)) {
if (!table_schema.is_user_table()) {
// only build_column_info_ for user table.
} else if (OB_ISNULL(allocator_)) {
ret = OB_ERR_UNEXPECTED;
DDLOG(WARN, "invalid allocator_", KR(ret));
} else if (OB_FAIL(table_schema.get_column_ids(column_ids))) {