[CP]clean tablet_ls_pair/ckm_sum_array when failed & add obtest
This commit is contained in:
		
							
								
								
									
										1
									
								
								deps/oblib/src/lib/utility/ob_tracepoint.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								deps/oblib/src/lib/utility/ob_tracepoint.h
									
									
									
									
										vendored
									
									
								
							@ -711,6 +711,7 @@ class EventTable
 | 
				
			|||||||
      EN_CO_MREGE_DAG_SCHEDULE_REST = 739,
 | 
					      EN_CO_MREGE_DAG_SCHEDULE_REST = 739,
 | 
				
			||||||
      EN_COMPACTION_SCHEDULE_MEDIUM_MERGE_AFTER_MINI = 740,
 | 
					      EN_COMPACTION_SCHEDULE_MEDIUM_MERGE_AFTER_MINI = 740,
 | 
				
			||||||
      EN_COMPACTION_MEDIUM_INIT_LARGE_PARALLEL_RANGE = 741,
 | 
					      EN_COMPACTION_MEDIUM_INIT_LARGE_PARALLEL_RANGE = 741,
 | 
				
			||||||
 | 
					      EN_GET_TABLET_LS_PAIR_IN_RS = 742,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // please add new trace point after 750
 | 
					      // please add new trace point after 750
 | 
				
			||||||
      EN_SESSION_LEAK_COUNT_THRESHOLD = 751,
 | 
					      EN_SESSION_LEAK_COUNT_THRESHOLD = 751,
 | 
				
			||||||
 | 
				
			|||||||
@ -219,6 +219,20 @@ int ObChecksumValidator::get_tablet_ls_pairs(
 | 
				
			|||||||
    } else if (OB_FAIL(tablet_ls_pair_cache_.get_tablet_ls_pairs(table_id_, tablet_ids, cur_tablet_ls_pair_array_))) {
 | 
					    } else if (OB_FAIL(tablet_ls_pair_cache_.get_tablet_ls_pairs(table_id_, tablet_ids, cur_tablet_ls_pair_array_))) {
 | 
				
			||||||
      LOG_WARN("failed to tablet ls pair", KR(ret), K(tablet_ids));
 | 
					      LOG_WARN("failed to tablet ls pair", KR(ret), K(tablet_ids));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
 | 
					#ifdef ERRSIM
 | 
				
			||||||
 | 
					        static int64_t enter_cnt = 0;
 | 
				
			||||||
 | 
					        if (OB_SUCC(ret) && simple_schema.is_global_index_table()) {
 | 
				
			||||||
 | 
					          ret = OB_E(EventTable::EN_GET_TABLET_LS_PAIR_IN_RS) OB_SUCCESS;
 | 
				
			||||||
 | 
					          if (OB_FAIL(ret)) {
 | 
				
			||||||
 | 
					            if (enter_cnt++ == 0) {
 | 
				
			||||||
 | 
					              ret = OB_ITEM_NOT_MATCH;
 | 
				
			||||||
 | 
					              STORAGE_LOG(INFO, "ERRSIM EN_GET_TABLET_LS_PAIR_IN_RS", K(ret), K(simple_schema), K_(cur_tablet_ls_pair_array));
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              ret = OB_SUCCESS;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
      LOG_TRACE("success to get tablet ls pairs", KR(ret), K_(cur_tablet_ls_pair_array));
 | 
					      LOG_TRACE("success to get tablet ls pairs", KR(ret), K_(cur_tablet_ls_pair_array));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -286,8 +300,9 @@ int ObChecksumValidator::validate_checksum(
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      last_table_ckm_items_.clear();
 | 
					      last_table_ckm_items_.clear();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    cur_tablet_ls_pair_array_.reuse();
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  cur_tablet_ls_pair_array_.reuse(); // need reuse array when get_tablet_ls_pairs failed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (FAILEDx(table_compaction_map_.set_refactored(table_id_, table_compaction_info_, true /*overwrite*/))) {
 | 
					  if (FAILEDx(table_compaction_map_.set_refactored(table_id_, table_compaction_info_, true /*overwrite*/))) {
 | 
				
			||||||
    LOG_WARN("fail to set refactored", KR(ret), K_(table_id), K_(table_compaction_info));
 | 
					    LOG_WARN("fail to set refactored", KR(ret), K_(table_id), K_(table_compaction_info));
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
 | 
				
			|||||||
@ -242,14 +242,18 @@ int ObTableCkmItems::build_column_ckm_sum_array(
 | 
				
			|||||||
    ret = OB_ERR_UNEXPECTED;
 | 
					    ret = OB_ERR_UNEXPECTED;
 | 
				
			||||||
    LOG_WARN("checksum items or tablet pairs are empty", KR(ret), K_(ckm_items), K_(tablet_pairs));
 | 
					    LOG_WARN("checksum items or tablet pairs are empty", KR(ret), K_(ckm_items), K_(tablet_pairs));
 | 
				
			||||||
  } else if (!ckm_sum_array_.empty()) {
 | 
					  } else if (!ckm_sum_array_.empty()) {
 | 
				
			||||||
    // inited before
 | 
					    LOG_INFO("use cached ckm array", KR(ret), K_(row_count), K_(ckm_sum_array), K(compaction_scn));
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
 | 
					    row_count_ = 0;
 | 
				
			||||||
 | 
					    ckm_sum_array_.reuse();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const int64_t column_checksums_cnt = ckm_items_.at(0).column_meta_.column_checksums_.count();
 | 
					    const int64_t column_checksums_cnt = ckm_items_.at(0).column_meta_.column_checksums_.count();
 | 
				
			||||||
    uint64_t pre_tablet_id = OB_INVALID_ID;
 | 
					    uint64_t pre_tablet_id = OB_INVALID_ID;
 | 
				
			||||||
    if (OB_FAIL(ckm_sum_array_.reserve(column_checksums_cnt))) {
 | 
					    if (OB_FAIL(ckm_sum_array_.reserve(column_checksums_cnt))) {
 | 
				
			||||||
      LOG_WARN("failed to reserve tablet column checksum array", KR(ret));
 | 
					      LOG_WARN("failed to reserve tablet column checksum array", KR(ret));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // items are order by tablet_id
 | 
					    // items are order by tablet_id
 | 
				
			||||||
 | 
					    int64_t pair_idx = 0;
 | 
				
			||||||
    for (int64_t i = 0; OB_SUCC(ret) && (i < items_cnt); ++i) {
 | 
					    for (int64_t i = 0; OB_SUCC(ret) && (i < items_cnt); ++i) {
 | 
				
			||||||
      const ObTabletReplicaChecksumItem &cur_item = ckm_items_.at(i);
 | 
					      const ObTabletReplicaChecksumItem &cur_item = ckm_items_.at(i);
 | 
				
			||||||
      LOG_TRACE("build_column_ckm_sum_array", KR(ret), K(i), K(cur_item), K(compaction_scn), K(row_cnt));
 | 
					      LOG_TRACE("build_column_ckm_sum_array", KR(ret), K(i), K(cur_item), K(compaction_scn), K(row_cnt));
 | 
				
			||||||
@ -271,7 +275,15 @@ int ObTableCkmItems::build_column_ckm_sum_array(
 | 
				
			|||||||
          } // end of for
 | 
					          } // end of for
 | 
				
			||||||
          row_count_ += cur_item.row_count_;
 | 
					          row_count_ += cur_item.row_count_;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        pre_tablet_id = cur_item.tablet_id_.id();
 | 
					
 | 
				
			||||||
 | 
					        if (OB_FAIL(ret)) {
 | 
				
			||||||
 | 
					        } else if (OB_UNLIKELY(cur_item.tablet_id_.id() != pre_tablet_id // meet new tablet
 | 
				
			||||||
 | 
					            && (pair_idx >= tablet_pairs_.count() || tablet_pairs_.at(pair_idx++).get_tablet_id() != cur_item.tablet_id_))) {
 | 
				
			||||||
 | 
					          ret = OB_ERR_UNEXPECTED;
 | 
				
			||||||
 | 
					          LOG_WARN("tablet pair and ckm items are mismatch", KR(ret), K(i), K(cur_item), K(tablet_pairs_), K(pair_idx));
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          pre_tablet_id = cur_item.tablet_id_.id();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        ret = OB_ITEM_NOT_MATCH;
 | 
					        ret = OB_ITEM_NOT_MATCH;
 | 
				
			||||||
        LOG_WARN("compaction scn mismtach", KR(ret), K(cur_item), K(compaction_scn));
 | 
					        LOG_WARN("compaction scn mismtach", KR(ret), K(cur_item), K(compaction_scn));
 | 
				
			||||||
@ -280,6 +292,9 @@ int ObTableCkmItems::build_column_ckm_sum_array(
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  if (OB_SUCC(ret)) {
 | 
					  if (OB_SUCC(ret)) {
 | 
				
			||||||
    row_cnt = row_count_;
 | 
					    row_cnt = row_count_;
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    row_count_ = 0;
 | 
				
			||||||
 | 
					    ckm_sum_array_.reuse();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -523,11 +538,12 @@ void ObTableCkmItems::reset()
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  is_inited_ = false;
 | 
					  is_inited_ = false;
 | 
				
			||||||
  table_id_ = 0;
 | 
					  table_id_ = 0;
 | 
				
			||||||
 | 
					  row_count_ = 0;
 | 
				
			||||||
 | 
					  table_schema_ = NULL;
 | 
				
			||||||
  tablet_pairs_.reset();
 | 
					  tablet_pairs_.reset();
 | 
				
			||||||
  ckm_items_.reset();
 | 
					  ckm_items_.reset();
 | 
				
			||||||
  sort_col_id_array_.reset();
 | 
					  sort_col_id_array_.reset();
 | 
				
			||||||
  ckm_sum_array_.reset();
 | 
					  ckm_sum_array_.reset();
 | 
				
			||||||
  row_count_ = 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace compaction
 | 
					} // namespace compaction
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user