[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)); DDLOG(WARN, "invalid table_schema", KR(ret));
} else { } else {
is_filtered = is_filtered =
! (table_schema->is_user_table() ! (table_schema->has_tablet()
|| table_schema->is_user_table()
|| table_schema->is_unique_index() || table_schema->is_unique_index()
|| table_schema->is_tmp_table()); || 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; int ret = OB_SUCCESS;
const common::ObIndexInfo &index_info = table_schema.get_index_info(); const common::ObIndexInfo &index_info = table_schema.get_index_info();
const ObIArray<ObAuxTableMetaInfo> &simple_index_infos = table_schema.get_simple_index_infos(); 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_)) { if (table_schema.is_user_table()) {
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_table_id_arr // build index_table_id_arr
for (int i = 0; OB_SUCC(ret) &&i < simple_index_infos.count(); i++) { for (int i = 0; OB_SUCC(ret) &&i < simple_index_infos.count(); i++) {
ObAuxTableMetaInfo index_table_info; 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)); 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 if (OB_ISNULL(allocator_)) {
for (int i = 0; OB_SUCC(ret) && i < index_column_count_; i++) { ret = OB_ERR_UNEXPECTED;
ObIndexColumn *idx_col = new (index_cols_ + i) ObIndexColumn(); DDLOG(WARN, "invalid allocator_", KR(ret));
ObIndexColumn tmp_idx_col; } 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))) { 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)); DDLOG(WARN, "get_index_column from ObIndexInfo failed", KR(ret), K(index_info), K(i), KPC(this));
} else if (OB_ISNULL(idx_col)) { } else if (OB_ISNULL(idx_col)) {
ret = OB_INVALID_DATA; ret = OB_INVALID_DATA;
DDLOG(WARN, "expect valid index_column", KR(ret), K(index_info), K(i), KPC(this)); DDLOG(WARN, "expect valid index_column", KR(ret), K(index_info), K(i), KPC(this));
} else { } else {
*idx_col = tmp_idx_col; *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; 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 ObDictTableMeta::build_rowkey_info_(const schema::ObTableSchema &table_schema)
{ {
int ret = OB_SUCCESS; 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) { if (!table_schema.is_user_table()) {
DDLOG(TRACE, "not found rowkey cols, skip", KPC(this)); // only record rowkey column info for user table.
} 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 { } else {
for (int i = 0; OB_SUCC(ret) && i < rowkey_column_count_; i++) { const common::ObRowkeyInfo &rowkey_info = table_schema.get_rowkey_info();
ObRowkeyColumn *rowkey_col = new (rowkey_cols_ + i) ObRowkeyColumn(); rowkey_column_count_ = rowkey_info.get_size();
ObRowkeyColumn tmp_rowkey_col; const int64_t alloc_size = sizeof(common::ObRowkeyColumn) * rowkey_column_count_;
if (OB_FAIL(rowkey_info.get_column(i, tmp_rowkey_col))) { if (rowkey_column_count_ <= 0) {
DDLOG(WARN, "get_rowkey_column from ObRowkeyInfo failed", KR(ret), K(rowkey_info), K(i), KPC(this)); DDLOG(TRACE, "not found rowkey cols, skip", KPC(this));
} else if (OB_ISNULL(rowkey_col)) { } else if (OB_ISNULL(rowkey_cols_ = static_cast<ObRowkeyColumn*>(allocator_->alloc(alloc_size)))) {
ret = OB_INVALID_DATA; ret = OB_ALLOCATE_MEMORY_FAILED;
DDLOG(WARN, "expect valid rowkey_column", KR(ret), K(rowkey_info), K(i), KPC(this)); DDLOG(WARN, "alloc for rowkey_cols_ failed", KR(ret), K(alloc_size), KPC(this));
} else { } else {
*rowkey_col = tmp_rowkey_col; 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; int ret = OB_SUCCESS;
common::ObArray<share::schema::ObColDesc> column_ids; 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; ret = OB_ERR_UNEXPECTED;
DDLOG(WARN, "invalid allocator_", KR(ret)); DDLOG(WARN, "invalid allocator_", KR(ret));
} else if (OB_FAIL(table_schema.get_column_ids(column_ids))) { } else if (OB_FAIL(table_schema.get_column_ids(column_ids))) {