diff --git a/src/storage/ddl/ob_complement_data_task.cpp b/src/storage/ddl/ob_complement_data_task.cpp index 8c2b584f4e..6fb2023d3d 100644 --- a/src/storage/ddl/ob_complement_data_task.cpp +++ b/src/storage/ddl/ob_complement_data_task.cpp @@ -225,14 +225,14 @@ int ObComplementDataContext::init(const ObComplementDataParam ¶m, const ObDa { int ret = OB_SUCCESS; void *builder_buf = nullptr; - const ObSSTable *latest_major_sstable = nullptr; + const ObSSTable *first_major_sstable = nullptr; if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("ObComplementDataContext has already been inited", K(ret)); } else if (OB_UNLIKELY(!param.is_valid() || !desc.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arguments", K(ret), K(param), K(desc)); - } else if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(param.ls_id_, param.dest_tablet_id_, latest_major_sstable))) { + } else if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(param.ls_id_, param.dest_tablet_id_, first_major_sstable))) { LOG_WARN("check if major sstable exist failed", K(ret), K(param)); } else if (OB_FAIL(data_sstable_redo_writer_.init(param.ls_id_, param.dest_tablet_id_))) { @@ -250,7 +250,7 @@ int ObComplementDataContext::init(const ObComplementDataParam ¶m, const ObDa ObSSTableIndexBuilder::DISABLE))) { LOG_WARN("failed to init index builder", K(ret), K(desc)); } else { - is_major_sstable_exist_ = nullptr != latest_major_sstable ? true : false; + is_major_sstable_exist_ = nullptr != first_major_sstable ? true : false; concurrent_cnt_ = param.concurrent_cnt_; is_inited_ = true; } @@ -1204,10 +1204,10 @@ int ObComplementMergeTask::process() } else if (OB_FAIL(guard.switch_to(param_->tenant_id_))) { LOG_WARN("switch to tenant failed", K(ret), K(param_->tenant_id_)); } else if (context_->is_major_sstable_exist_) { - const ObSSTable *latest_major_sstable = nullptr; - if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(param_->ls_id_, param_->dest_tablet_id_, latest_major_sstable))) { + const ObSSTable *first_major_sstable = nullptr; + if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(param_->ls_id_, param_->dest_tablet_id_, first_major_sstable))) { LOG_WARN("check if major sstable exist failed", K(ret), K(*param_)); - } else if (OB_ISNULL(latest_major_sstable)) { + } else if (OB_ISNULL(first_major_sstable)) { 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_, @@ -1215,7 +1215,7 @@ int ObComplementMergeTask::process() param_->dest_table_id_, 1 /* execution_id */, param_->task_id_, - latest_major_sstable->get_meta().get_col_checksum()))) { + 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_)); diff --git a/src/storage/ddl/ob_ddl_merge_task.cpp b/src/storage/ddl/ob_ddl_merge_task.cpp index 098e68ec83..d234052682 100644 --- a/src/storage/ddl/ob_ddl_merge_task.cpp +++ b/src/storage/ddl/ob_ddl_merge_task.cpp @@ -363,10 +363,10 @@ int ObDDLTableMergeTask::process() ObTabletDDLParam ddl_param; ObTableHandleV2 table_handle; bool is_data_complete = false; - const ObSSTable *latest_major_sstable = nullptr; - if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(merge_param_.ls_id_, merge_param_.tablet_id_, latest_major_sstable))) { + const ObSSTable *first_major_sstable = nullptr; + if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(merge_param_.ls_id_, merge_param_.tablet_id_, first_major_sstable))) { LOG_WARN("check if major sstable exist failed", K(ret)); - } else if (nullptr != latest_major_sstable) { + } else if (nullptr != first_major_sstable) { LOG_INFO("major sstable has been created before", K(merge_param_), K(ddl_param.table_key_)); sstable = static_cast(tablet_handle.get_obj()->get_table_store().get_major_sstables().get_boundary_table(false/*first*/)); } else if (tablet_handle.get_obj()->get_tablet_meta().table_store_flag_.with_major_sstable()) { @@ -404,15 +404,6 @@ int ObDDLTableMergeTask::process() } else if (OB_ISNULL(sstable)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("ddl major sstable is null", K(ret), K(ddl_param)); - } else if (merge_param_.table_id_ > 0 - && merge_param_.execution_id_ >= 0 - && OB_FAIL(ObTabletDDLUtil::report_ddl_checksum(merge_param_.ls_id_, - merge_param_.tablet_id_, - merge_param_.table_id_, - merge_param_.execution_id_, - merge_param_.ddl_task_id_, - sstable->get_meta().get_col_checksum()))) { - LOG_WARN("report ddl column checksum failed", K(ret), K(merge_param_)); } else if (OB_FAIL(GCTX.ob_service_->submit_tablet_update_task(tenant_id, merge_param_.ls_id_, merge_param_.tablet_id_))) { LOG_WARN("fail to submit tablet update task", K(ret), K(tenant_id), K(merge_param_)); } @@ -971,12 +962,12 @@ int ObTabletDDLUtil::report_ddl_checksum(const share::ObLSID &ls_id, int ObTabletDDLUtil::check_and_get_major_sstable(const share::ObLSID &ls_id, const ObTabletID &tablet_id, - const ObSSTable *&latest_major_sstable) + const ObSSTable *&first_major_sstable) { int ret = OB_SUCCESS; ObLSHandle ls_handle; ObTabletHandle tablet_handle; - latest_major_sstable = nullptr; + first_major_sstable = nullptr; if (OB_UNLIKELY(!ls_id.is_valid() || !tablet_id.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(ls_id), K(tablet_id)); @@ -991,8 +982,8 @@ int ObTabletDDLUtil::check_and_get_major_sstable(const share::ObLSID &ls_id, ret = OB_ERR_SYS; LOG_WARN("tablet handle is null", K(ret), K(ls_id), K(tablet_id)); } else { - latest_major_sstable = static_cast( - tablet_handle.get_obj()->get_table_store().get_major_sstables().get_boundary_table(true/*last*/)); + first_major_sstable = static_cast( + tablet_handle.get_obj()->get_table_store().get_major_sstables().get_boundary_table(false/*first*/)); } return ret; } diff --git a/src/storage/ddl/ob_ddl_merge_task.h b/src/storage/ddl/ob_ddl_merge_task.h index 61ff58ae8a..e19b0f407e 100644 --- a/src/storage/ddl/ob_ddl_merge_task.h +++ b/src/storage/ddl/ob_ddl_merge_task.h @@ -182,7 +182,7 @@ public: const ObIArray &column_checksums); static int check_and_get_major_sstable(const share::ObLSID &ls_id, const ObTabletID &tablet_id, - const blocksstable::ObSSTable *&latest_major_sstable); + const blocksstable::ObSSTable *&first_major_sstable); static int check_data_integrity(const ObTablesHandleArray &ddl_sstables, const share::SCN &start_scn, diff --git a/src/storage/ddl/ob_ddl_redo_log_writer.cpp b/src/storage/ddl/ob_ddl_redo_log_writer.cpp index 3ea51d8c25..cf640fb180 100644 --- a/src/storage/ddl/ob_ddl_redo_log_writer.cpp +++ b/src/storage/ddl/ob_ddl_redo_log_writer.cpp @@ -23,6 +23,7 @@ #include "storage/ls/ob_ls.h" #include "storage/tx_storage/ob_ls_service.h" #include "storage/tx/ob_ts_mgr.h" +#include "storage/ddl/ob_ddl_merge_task.h" #include "storage/ddl/ob_tablet_ddl_kv_mgr.h" #include "storage/blocksstable/ob_logic_macro_id.h" #include "observer/ob_server_event_history_table_operator.h" @@ -1202,6 +1203,31 @@ int ObDDLSSTableRedoWriter::end_ddl_redo_and_create_ddl_sstable( } else { LOG_WARN("failed to wait ddl merge", K(ret), K(ddl_start_scn)); } + } else { + const ObSSTable *first_major_sstable = nullptr; + if (OB_FAIL(ObTabletDDLUtil::check_and_get_major_sstable(ls_id, tablet_id, first_major_sstable))) { + LOG_WARN("failed to get first major sstable", K(ret), K(ls_id), K(tablet_id)); + } else if (OB_ISNULL(first_major_sstable)) { + ret = OB_ERR_UNEXPECTED; + 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)) { + ret = OB_SNAPSHOT_DISCARDED; + LOG_WARN("ddl major sstable dropped, snapshot holding may have bug", K(ret), KPC(first_major_sstable), K(table_key), K(tablet_id), K(execution_id), K(ddl_task_id)); + } else { + for (int64_t retry_cnt = 10; retry_cnt > 0; retry_cnt--) { // overwrite ret + if (OB_FAIL(ObTabletDDLUtil::report_ddl_checksum(ls_id, + tablet_id, + table_id, + execution_id, + ddl_task_id, + first_major_sstable->get_meta().get_col_checksum()))) { + LOG_WARN("report ddl column checksum failed", K(ret), K(ls_id), K(tablet_id), K(execution_id), K(ddl_task_id)); + } else { + break; + } + ob_usleep(100L * 1000L); + } + } } return ret; }