Fix used-after-free of sstable ptr

This commit is contained in:
Hongqin-Li
2023-05-31 08:47:28 +00:00
committed by ob-robot
parent fa31710cf2
commit 938641501d
2 changed files with 38 additions and 19 deletions

View File

@ -1193,6 +1193,7 @@ int ObComplementMergeTask::process()
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
ObIDag *tmp_dag = get_dag(); ObIDag *tmp_dag = get_dag();
ObComplementDataDag *dag = nullptr; ObComplementDataDag *dag = nullptr;
ObLSHandle ls_handle;
ObTabletHandle tablet_handle; ObTabletHandle tablet_handle;
ObTablet *tablet = nullptr; ObTablet *tablet = nullptr;
if (OB_ISNULL(tmp_dag) || ObDagType::DAG_TYPE_DDL != tmp_dag->get_type()) { if (OB_ISNULL(tmp_dag) || ObDagType::DAG_TYPE_DDL != tmp_dag->get_type()) {
@ -1204,21 +1205,32 @@ int ObComplementMergeTask::process()
} else if (OB_FAIL(guard.switch_to(param_->tenant_id_))) { } else if (OB_FAIL(guard.switch_to(param_->tenant_id_))) {
LOG_WARN("switch to tenant failed", K(ret), K(param_->tenant_id_)); LOG_WARN("switch to tenant failed", K(ret), K(param_->tenant_id_));
} else if (context_->is_major_sstable_exist_) { } else if (context_->is_major_sstable_exist_) {
const ObSSTable *first_major_sstable = nullptr; if (OB_FAIL(MTL(ObLSService *)->get_ls(param_->ls_id_, ls_handle, ObLSGetMod::DDL_MOD))) {
if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(param_->ls_id_, param_->dest_tablet_id_, first_major_sstable))) { LOG_WARN("failed to get log stream", K(ret), K(*param_));
LOG_WARN("check if major sstable exist failed", K(ret), K(*param_)); } else if (OB_FAIL(ObDDLUtil::ddl_get_tablet(ls_handle,
} else if (OB_ISNULL(first_major_sstable)) { param_->dest_tablet_id_,
ret = OB_ERR_UNEXPECTED; tablet_handle,
LOG_WARN("unexpected error, major sstable shoud not be null", K(ret), K(*param_)); ObTabletCommon::NO_CHECK_GET_TABLET_TIMEOUT_US))) {
} else if (OB_FAIL(ObTabletDDLUtil::report_ddl_checksum(param_->ls_id_, LOG_WARN("get tablet handle failed", K(ret), K(*param_));
param_->dest_tablet_id_, } else if (OB_ISNULL(tablet_handle.get_obj())) {
param_->dest_table_id_, ret = OB_ERR_SYS;
1 /* execution_id */, LOG_WARN("tablet handle is null", K(ret), K(*param_));
param_->task_id_, } else {
first_major_sstable->get_meta().get_col_checksum()))) { const ObSSTable *first_major_sstable = static_cast<ObSSTable *>(
LOG_WARN("report ddl column checksum failed", K(ret), K(*param_)); tablet_handle.get_obj()->get_table_store().get_major_sstables().get_boundary_table(false/*first*/));
} else if (OB_FAIL(GCTX.ob_service_->submit_tablet_update_task(param_->tenant_id_, param_->ls_id_, param_->dest_tablet_id_))) { if (OB_ISNULL(first_major_sstable)) {
LOG_WARN("fail to submit tablet update task", K(ret), K(*param_)); ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected error, major sstable shoud not be null", K(ret), K(*param_));
} else if (OB_FAIL(ObTabletDDLUtil::report_ddl_checksum(param_->ls_id_,
param_->dest_tablet_id_,
param_->dest_table_id_,
1 /* execution_id */,
param_->task_id_,
first_major_sstable->get_meta().get_col_checksum()))) {
LOG_WARN("report ddl column checksum failed", K(ret), K(*param_));
} else if (OB_FAIL(GCTX.ob_service_->submit_tablet_update_task(param_->tenant_id_, param_->ls_id_, param_->dest_tablet_id_))) {
LOG_WARN("fail to submit tablet update task", K(ret), K(*param_));
}
} }
} else if (OB_FAIL(add_build_hidden_table_sstable())) { } else if (OB_FAIL(add_build_hidden_table_sstable())) {
LOG_WARN("fail to build new sstable and write macro redo", K(ret)); LOG_WARN("fail to build new sstable and write macro redo", K(ret));

View File

@ -1203,11 +1203,18 @@ int ObDDLSSTableRedoWriter::end_ddl_redo_and_create_ddl_sstable(
} else { } else {
LOG_WARN("failed to wait ddl merge", K(ret), K(ddl_start_scn)); LOG_WARN("failed to wait ddl merge", K(ret), K(ddl_start_scn));
} }
} else if (OB_FAIL(ObDDLUtil::ddl_get_tablet(ls_handle,
tablet_id,
tablet_handle,
ObTabletCommon::NO_CHECK_GET_TABLET_TIMEOUT_US))) {
LOG_WARN("get tablet handle failed", K(ret), K(ls_id), K(tablet_id));
} else if (OB_ISNULL(tablet_handle.get_obj())) {
ret = OB_ERR_SYS;
LOG_WARN("tablet handle is null", K(ret), K(ls_id), K(tablet_id));
} else { } else {
const ObSSTable *first_major_sstable = nullptr; ObSSTable *first_major_sstable = static_cast<ObSSTable *>(
if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(ls_id, tablet_id, first_major_sstable))) { tablet_handle.get_obj()->get_table_store().get_major_sstables().get_boundary_table(false/*first*/));
LOG_WARN("failed to get first major sstable", K(ret), K(ls_id), K(tablet_id)); if (OB_ISNULL(first_major_sstable)) {
} else if (OB_ISNULL(first_major_sstable)) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("no major after wait merge success", K(ret), K(ls_id), K(tablet_id)); LOG_WARN("no major after wait merge success", K(ret), K(ls_id), K(tablet_id));
} else if (OB_UNLIKELY(first_major_sstable->get_key() != table_key)) { } else if (OB_UNLIKELY(first_major_sstable->get_key() != table_key)) {