diff --git a/src/rootserver/ddl_task/ob_ddl_retry_task.cpp b/src/rootserver/ddl_task/ob_ddl_retry_task.cpp index c022d864e..2a5277622 100644 --- a/src/rootserver/ddl_task/ob_ddl_retry_task.cpp +++ b/src/rootserver/ddl_task/ob_ddl_retry_task.cpp @@ -620,7 +620,7 @@ int ObDDLRetryTask::update_task_status_wait_child_task_finish( int64_t affected_rows = 0; ObSqlString sql_string; int64_t curr_task_status = 0; - int64_t execution_id = 0; /*unused*/ + int64_t execution_id = -1; /*unused*/ const int64_t new_task_status = ObDDLTaskStatus::WAIT_CHILD_TASK_FINISH; if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || task_id <= 0)) { ret = OB_INVALID_ARGUMENT; diff --git a/src/rootserver/ddl_task/ob_ddl_scheduler.cpp b/src/rootserver/ddl_task/ob_ddl_scheduler.cpp index 3bb837901..c72709e98 100644 --- a/src/rootserver/ddl_task/ob_ddl_scheduler.cpp +++ b/src/rootserver/ddl_task/ob_ddl_scheduler.cpp @@ -902,7 +902,7 @@ int ObDDLScheduler::recover_task() const ObDDLTaskRecord &cur_record = task_records.at(i); int64_t tenant_schema_version = 0; int64_t table_task_status = 0; - int64_t execution_id = 0; + int64_t execution_id = -1; ObMySQLTransaction trans; if (OB_FAIL(schema_service.get_tenant_schema_version(cur_record.tenant_id_, tenant_schema_version))) { LOG_WARN("failed to get tenant schema version", K(ret), K(cur_record)); @@ -1317,9 +1317,8 @@ int ObDDLScheduler::on_update_execution_id( K(ret), K(task_id), KPC(ddl_task)); } else if (OB_FAIL(ddl_task->push_execution_id())) { LOG_WARN("fail to push execution id", K(ret), KPC(ddl_task)); - } else { - ret_execution_id = ddl_task->get_execution_id(); } + ret_execution_id = ddl_task->get_execution_id(); // ignore ret, if fail, take old execution id } return ret; } @@ -1335,7 +1334,7 @@ int ObDDLScheduler::on_sstable_complement_job_reply( if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not init", K(ret)); - } else if (OB_UNLIKELY(!(task_key.is_valid() && snapshot_version > 0 && execution_id > 0))) { + } else if (OB_UNLIKELY(!(task_key.is_valid() && snapshot_version > 0 && execution_id >= 0))) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(task_key), K(snapshot_version), K(execution_id), K(ret_code)); } else { diff --git a/src/rootserver/ddl_task/ob_ddl_single_replica_executor.h b/src/rootserver/ddl_task/ob_ddl_single_replica_executor.h index 450262a24..0d483be81 100644 --- a/src/rootserver/ddl_task/ob_ddl_single_replica_executor.h +++ b/src/rootserver/ddl_task/ob_ddl_single_replica_executor.h @@ -36,14 +36,14 @@ public: snapshot_version_(0), task_id_(0), parallelism_(0), - execution_id_(0) + execution_id_(-1) {} ~ObDDLSingleReplicaExecutorParam() = default; bool is_valid() const { return common::OB_INVALID_TENANT_ID != tenant_id_ && share::DDL_INVALID != type_ && source_tablet_ids_.count() > 0 && dest_tablet_ids_.count() > 0 && common::OB_INVALID_ID != source_table_id_ && common::OB_INVALID_ID != dest_table_id_ - && schema_version_ > 0 && snapshot_version_ > 0 && task_id_ > 0 && execution_id_ > 0; + && schema_version_ > 0 && snapshot_version_ > 0 && task_id_ > 0 && execution_id_ >= 0; } TO_STRING_KV(K_(tenant_id), K_(type), K_(source_tablet_ids), K_(dest_tablet_ids), K_(source_table_id), K_(dest_table_id), K_(schema_version), diff --git a/src/rootserver/ddl_task/ob_ddl_task.cpp b/src/rootserver/ddl_task/ob_ddl_task.cpp index ab888f197..427732a75 100644 --- a/src/rootserver/ddl_task/ob_ddl_task.cpp +++ b/src/rootserver/ddl_task/ob_ddl_task.cpp @@ -320,7 +320,7 @@ int ObDDLTask::switch_status(ObDDLTaskStatus new_status, const int ret_code) LOG_WARN("start transaction failed", K(ret)); } else { int64_t table_task_status = 0; - int64_t execution_id = 0; + int64_t execution_id = -1; if (OB_FAIL(ObDDLTaskRecordOperator::select_for_update(trans, tenant_id_, task_id_, table_task_status, execution_id))) { LOG_WARN("select for update failed", K(ret), K(task_id_)); } else if (old_status != task_status_) { @@ -607,8 +607,6 @@ int ObDDLTask::push_execution_id() LOG_WARN("select for update failed", K(ret), K(task_id)); } else if (OB_FAIL(ObDDLTaskRecordOperator::update_execution_id(trans, tenant_id_, task_id_, table_execution_id + 1))) { LOG_WARN("update task status failed", K(ret)); - } else { - execution_id_ = table_execution_id + 1; } bool commit = (OB_SUCCESS == ret); int tmp_ret = trans.end(commit); @@ -616,6 +614,11 @@ int ObDDLTask::push_execution_id() LOG_WARN("fail to end trans", K(tmp_ret)); ret = (OB_SUCCESS == ret) ? tmp_ret : ret; } + if (OB_SUCC(ret)) { + execution_id_ = table_execution_id + 1; + } else { + execution_id_ = execution_id_ >= 0 ? execution_id_ : 0; // use old execution or inner table default value(0) + } } return ret; } @@ -1178,7 +1181,7 @@ int ObDDLWaitColumnChecksumCtx::init( const uint64_t target_table_id, const int64_t schema_version, const int64_t snapshot_version, - const uint64_t execution_id, + const int64_t execution_id, const int64_t timeout_us) { int ret = OB_SUCCESS; @@ -1192,7 +1195,7 @@ int ObDDLWaitColumnChecksumCtx::init( || OB_INVALID_ID == target_table_id || schema_version <= 0 || snapshot_version <= 0 - || OB_INVALID_ID == execution_id + || execution_id < 0 || timeout_us <= 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(task_id), K(tenant_id), K(source_table_id), K(target_table_id), @@ -1248,7 +1251,7 @@ void ObDDLWaitColumnChecksumCtx::reset() target_table_id_ = OB_INVALID_ID; schema_version_ = 0; snapshot_version_ = 0; - execution_id_ = OB_INVALID_ID; + execution_id_ = -1; timeout_us_ = 0; last_drive_ts_ = 0; stat_array_.reset(); @@ -1507,7 +1510,7 @@ bool ObDDLTaskRecord::is_valid() const && task_version_ > 0 && OB_INVALID_ID != object_id_ && schema_version_ > 0 - && execution_id_ >= 0; + && execution_id_ >= -1; return is_valid; } @@ -1526,7 +1529,7 @@ void ObDDLTaskRecord::reset() message_.reset(); task_version_ = 0; ret_code_ = OB_SUCCESS; - execution_id_ = 0; + execution_id_ = -1; // -1 is invalid } @@ -1612,7 +1615,7 @@ int ObDDLTaskRecordOperator::update_execution_id( int ret = OB_SUCCESS; ObSqlString sql_string; int64_t affected_rows = 0; - if (OB_ISNULL(sql_client.get_pool()) || OB_UNLIKELY(task_id <= 0 || tenant_id <= 0 || execution_id <= 0)) { + if (OB_ISNULL(sql_client.get_pool()) || OB_UNLIKELY(task_id <= 0 || tenant_id <= 0 || execution_id < 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arg", K(ret), K(tenant_id), K(task_id)); } else if (OB_FAIL(sql_string.assign_fmt(" UPDATE %s SET execution_id=%lu WHERE task_id=%lu ", @@ -1909,7 +1912,7 @@ int ObDDLTaskRecordOperator::insert_record( LOG_WARN("append hex escaped string failed", K(ret)); } else if (OB_FAIL(sql_string.assign_fmt( " INSERT INTO %s (task_id, parent_task_id, tenant_id, object_id, schema_version, target_object_id, ddl_type, trace_id, status, task_version, execution_id, ret_code, ddl_stmt_str, message) " - " VALUES (%lu, %lu, %lu, %lu, %lu, %lu, %d, '%s', %ld, %lu, %lu, %lu, '%.*s', \"%.*s\") ", + " VALUES (%lu, %lu, %lu, %lu, %lu, %lu, %d, '%s', %ld, %lu, %ld, %lu, '%.*s', \"%.*s\") ", OB_ALL_DDL_TASK_STATUS_TNAME, record.task_id_, record.parent_task_id_, ObSchemaUtils::get_extract_tenant_id(record.tenant_id_, record.tenant_id_), record.object_id_, record.schema_version_, get_record_id(record.ddl_type_, record.target_object_id_), record.ddl_type_, trace_id_str, record.task_status_, record.task_version_, record.execution_id_, record.ret_code_, @@ -2012,7 +2015,7 @@ int ObDDLTaskRecordOperator::select_for_update( int ret = OB_SUCCESS; ObSqlString sql_string; task_status = 0; - execution_id = 0; + execution_id = 0; // default in OB_ALL_DDL_TASK_STATUS_TNAME is 0 if (OB_UNLIKELY(task_id <= 0 || tenant_id <= 0)) { ret = OB_NOT_INIT; LOG_WARN("not init", K(ret), K(tenant_id), K(task_id)); diff --git a/src/rootserver/ddl_task/ob_ddl_task.h b/src/rootserver/ddl_task/ob_ddl_task.h index a48922ce3..335a9d3e9 100644 --- a/src/rootserver/ddl_task/ob_ddl_task.h +++ b/src/rootserver/ddl_task/ob_ddl_task.h @@ -274,7 +274,7 @@ public: target_object_id_(0), task_status_(share::ObDDLTaskStatus::PREPARE), snapshot_version_(0), ret_code_(OB_SUCCESS), task_id_(0), parent_task_id_(0), parent_task_key_(), task_version_(0), parallelism_(0), allocator_(lib::ObLabel("DdlTask")), compat_mode_(lib::Worker::CompatMode::INVALID), err_code_occurence_cnt_(0), - delay_schedule_time_(0), next_schedule_ts_(0), execution_id_(0), sql_exec_addr_() + delay_schedule_time_(0), next_schedule_ts_(0), execution_id_(-1), sql_exec_addr_() {} virtual ~ObDDLTask() {} virtual int process() = 0; @@ -387,18 +387,18 @@ struct PartitionColChecksumStat : tablet_id_(), col_checksum_stat_(CCS_INVALID), snapshot_(-1), - execution_id_(common::OB_INVALID_ID), + execution_id_(-1), ret_code_(OB_SUCCESS) {} void reset() { tablet_id_.reset(); col_checksum_stat_ = CCS_INVALID; snapshot_ = -1; - execution_id_ = common::OB_INVALID_ID; + execution_id_ = -1; ret_code_ = common::OB_SUCCESS; table_id_ = common::OB_INVALID_ID; } - bool is_valid() const { return tablet_id_.is_valid() && common::OB_INVALID_ID != execution_id_ && common::OB_INVALID_ID != table_id_; } + bool is_valid() const { return tablet_id_.is_valid() && execution_id_ >= 0 && common::OB_INVALID_ID != table_id_; } TO_STRING_KV(K_(tablet_id), K_(col_checksum_stat), K_(snapshot), @@ -407,7 +407,7 @@ struct PartitionColChecksumStat ObTabletID tablet_id_; // may be data table, local index or global index ColChecksumStat col_checksum_stat_; int64_t snapshot_; - uint64_t execution_id_; + int64_t execution_id_; int ret_code_; int64_t table_id_; }; @@ -424,7 +424,7 @@ public: const uint64_t target_table_id, const int64_t schema_version, const int64_t snapshot_version, - const uint64_t execution_id, + const int64_t execution_id, const int64_t timeout_us); void reset(); bool is_inited() const { return is_inited_; } diff --git a/src/share/ob_build_index_struct.h b/src/share/ob_build_index_struct.h index 5c018eeed..985b7275f 100644 --- a/src/share/ob_build_index_struct.h +++ b/src/share/ob_build_index_struct.h @@ -23,19 +23,19 @@ namespace share struct ObBuildIndexAppendLocalDataParam { ObBuildIndexAppendLocalDataParam() - : execution_id_(common::OB_INVALID_ID), task_id_(common::OB_INVALID_ID), + : execution_id_(-1), task_id_(common::OB_INVALID_ID), index_id_(common::OB_INVALID_ID), schema_version_(common::OB_INVALID_VERSION), task_cnt_(0) {} virtual ~ObBuildIndexAppendLocalDataParam() {} bool is_valid() const { - return common::OB_INVALID_ID != execution_id_ && common::OB_INVALID_ID != task_id_ + return 0 <= execution_id_ && common::OB_INVALID_ID != task_id_ && common::OB_INVALID_ID != index_id_ && common::OB_INVALID_VERSION != schema_version_ && 0 != task_cnt_ && task_id_ < task_cnt_; } TO_STRING_KV(K_(execution_id), K_(task_id), K_(index_id), K_(schema_version), K_(task_cnt)); - uint64_t execution_id_; + int64_t execution_id_; uint64_t task_id_; uint64_t index_id_; int64_t schema_version_; @@ -45,18 +45,18 @@ struct ObBuildIndexAppendLocalDataParam struct ObBuildIndexAppendSSTableParam { ObBuildIndexAppendSSTableParam() - : index_id_(common::OB_INVALID_ID), schema_version_(common::OB_INVALID_VERSION), execution_id_(common::OB_INVALID_ID) + : index_id_(common::OB_INVALID_ID), schema_version_(common::OB_INVALID_VERSION), execution_id_(-1) {} virtual ~ObBuildIndexAppendSSTableParam() {} bool is_valid() const { return common::OB_INVALID_ID != index_id_ && common::OB_INVALID_VERSION != schema_version_ - && common::OB_INVALID_ID != execution_id_; + && 0 <= execution_id_; } TO_STRING_KV(K_(index_id), K_(schema_version), K_(execution_id)); uint64_t index_id_; int64_t schema_version_; - uint64_t execution_id_; + int64_t execution_id_; }; } // end namespace share diff --git a/src/share/ob_ddl_checksum.cpp b/src/share/ob_ddl_checksum.cpp index 6c45bcbd9..db2a8224a 100644 --- a/src/share/ob_ddl_checksum.cpp +++ b/src/share/ob_ddl_checksum.cpp @@ -207,7 +207,7 @@ int ObDDLChecksumOperator::get_column_checksum(const ObSqlString &sql, const uin int ObDDLChecksumOperator::get_table_column_checksum( const uint64_t tenant_id, - const uint64_t execution_id, + const int64_t execution_id, const uint64_t table_id, const int64_t ddl_task_id, common::hash::ObHashMap &column_checksum_map, @@ -216,7 +216,7 @@ int ObDDLChecksumOperator::get_table_column_checksum( int ret = OB_SUCCESS; ObSqlString sql; const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id); - if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || OB_INVALID_ID == execution_id || OB_INVALID_ID == table_id + if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || execution_id < 0 || OB_INVALID_ID == table_id || OB_INVALID_ID == ddl_task_id || !column_checksum_map.created())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(tenant_id), K(execution_id), K(table_id), K(ddl_task_id), @@ -236,7 +236,7 @@ int ObDDLChecksumOperator::get_table_column_checksum( int ObDDLChecksumOperator::check_column_checksum( const uint64_t tenant_id, - const uint64_t execution_id, + const int64_t execution_id, const uint64_t data_table_id, const uint64_t index_table_id, const int64_t ddl_task_id, @@ -247,7 +247,7 @@ int ObDDLChecksumOperator::check_column_checksum( hash::ObHashMap data_table_column_checksums; hash::ObHashMap index_table_column_checksums; is_equal = true; - if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || OB_INVALID_ID == execution_id || OB_INVALID_ID == data_table_id + if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || execution_id < 0 || OB_INVALID_ID == data_table_id || OB_INVALID_ID == index_table_id || OB_INVALID_ID == ddl_task_id)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(tenant_id), K(execution_id), K(data_table_id), K(index_table_id), K(ddl_task_id)); @@ -286,7 +286,7 @@ int ObDDLChecksumOperator::check_column_checksum( int ObDDLChecksumOperator::delete_checksum( const uint64_t tenant_id, - const uint64_t execution_id, + const int64_t execution_id, const uint64_t source_table_id, const uint64_t dest_table_id, const int64_t ddl_task_id, @@ -296,7 +296,7 @@ int ObDDLChecksumOperator::delete_checksum( ObSqlString sql; int64_t affected_rows = 0; const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id); - if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || OB_INVALID_ID == execution_id || OB_INVALID_ID == ddl_task_id + if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || execution_id < 0 || OB_INVALID_ID == ddl_task_id || OB_INVALID_ID == source_table_id || OB_INVALID_ID == dest_table_id)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(tenant_id), K(execution_id), K(source_table_id), K(dest_table_id)); diff --git a/src/share/ob_ddl_checksum.h b/src/share/ob_ddl_checksum.h index 4a12692c6..1a708960c 100644 --- a/src/share/ob_ddl_checksum.h +++ b/src/share/ob_ddl_checksum.h @@ -26,14 +26,14 @@ namespace share struct ObDDLChecksumItem { ObDDLChecksumItem() - : execution_id_(common::OB_INVALID_ID), tenant_id_(common::OB_INVALID_ID), + : execution_id_(-1), tenant_id_(common::OB_INVALID_ID), table_id_(common::OB_INVALID_ID), ddl_task_id_(0), column_id_(common::OB_INVALID_ID), task_id_(common::OB_INVALID_ID), checksum_(0) {} ~ObDDLChecksumItem() {}; bool is_valid() const { - return common::OB_INVALID_ID != execution_id_ + return 0 <= execution_id_ && common::OB_INVALID_ID != tenant_id_ && common::OB_INVALID_ID != table_id_ && 0 < ddl_task_id_ @@ -41,7 +41,7 @@ struct ObDDLChecksumItem } TO_STRING_KV(K_(execution_id), K_(tenant_id), K_(table_id), K_(ddl_task_id), K_(column_id), K_(task_id), K_(checksum)); - uint64_t execution_id_; + int64_t execution_id_; uint64_t tenant_id_; uint64_t table_id_; int64_t ddl_task_id_; @@ -66,13 +66,13 @@ public: common::ObMySQLProxy &sql_proxy); static int get_table_column_checksum( const uint64_t tenant_id, - const uint64_t execution_id, + const int64_t execution_id, const uint64_t table_id, const int64_t ddl_task_id, common::hash::ObHashMap &column_checksums, common::ObMySQLProxy &sql_proxy); static int check_column_checksum( const uint64_t tenant_id, - const uint64_t execution_id, + const int64_t execution_id, const uint64_t data_table_id, const uint64_t index_table_id, const int64_t ddl_task_id, @@ -80,7 +80,7 @@ public: common::ObMySQLProxy &sql_proxy); static int delete_checksum( const uint64_t tenant_id, - const uint64_t execution_id, + const int64_t execution_id, const uint64_t source_table_id, const uint64_t dest_table_id, const int64_t ddl_task_id, diff --git a/src/share/ob_ddl_common.cpp b/src/share/ob_ddl_common.cpp index be56dea3d..478068f9a 100644 --- a/src/share/ob_ddl_common.cpp +++ b/src/share/ob_ddl_common.cpp @@ -442,7 +442,7 @@ int ObDDLUtil::generate_build_replica_sql( const ObTableSchema *dest_table_schema = nullptr; bool oracle_mode = false; if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || OB_INVALID_ID == data_table_id || OB_INVALID_ID == dest_table_id - || schema_version <= 0 || snapshot_version <= 0 || execution_id <= 0 || task_id <= 0)) { + || schema_version <= 0 || snapshot_version <= 0 || execution_id < 0 || task_id <= 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arguments", K(ret), K(tenant_id), K(data_table_id), K(dest_table_id), K(schema_version), K(snapshot_version), K(execution_id), K(task_id)); diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index e05cff596..912d71aa7 100644 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -2681,7 +2681,7 @@ OB_SERIALIZE_MEMBER( bool ObCalcColumnChecksumRequestArg::is_valid() const { bool bret = OB_INVALID_ID != tenant_id_ && OB_INVALID_ID != target_table_id_ - && OB_INVALID_VERSION != schema_version_ && OB_INVALID_ID != execution_id_ + && OB_INVALID_VERSION != schema_version_ && execution_id_ >= 0 && OB_INVALID_VERSION != snapshot_version_ && OB_INVALID_ID != source_table_id_ && task_id_ > 0; for (int64_t i = 0; bret && i < calc_items_.count(); ++i) { bret = calc_items_.at(i).is_valid(); @@ -2694,9 +2694,9 @@ void ObCalcColumnChecksumRequestArg::reset() tenant_id_ = OB_INVALID_ID; target_table_id_ = OB_INVALID_ID; schema_version_ = OB_INVALID_VERSION; - execution_id_ = OB_INVALID_ID; snapshot_version_ = OB_INVALID_VERSION; source_table_id_ = OB_INVALID_ID; + execution_id_ = -1; task_id_ = 0; calc_items_.reset(); } @@ -6708,7 +6708,7 @@ OB_SERIALIZE_MEMBER(ObRpcRemoteWriteDDLRedoLogArg, tenant_id_, ls_id_, redo_info ObRpcRemoteWriteDDLPrepareLogArg::ObRpcRemoteWriteDDLPrepareLogArg() : tenant_id_(OB_INVALID_ID), ls_id_(), table_key_(), start_scn_(SCN::min_scn()), - table_id_(0), execution_id_(0), ddl_task_id_(0) + table_id_(0), execution_id_(-1), ddl_task_id_(0) {} int ObRpcRemoteWriteDDLPrepareLogArg::init(const uint64_t tenant_id, @@ -6721,7 +6721,7 @@ int ObRpcRemoteWriteDDLPrepareLogArg::init(const uint64_t tenant_id, { int ret = OB_SUCCESS; if (OB_UNLIKELY(tenant_id == OB_INVALID_ID || !ls_id.is_valid() || !table_key.is_valid() || !start_scn.is_valid_and_not_min() - || table_id <= 0 || execution_id <= 0 || ddl_task_id <= 0)) { + || table_id <= 0 || execution_id < 0 || ddl_task_id <= 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("tablet id is not valid", K(ret), K(tenant_id), K(ls_id), K(table_key), K(start_scn), K(table_id), K(execution_id), K(ddl_task_id)); diff --git a/src/share/ob_rpc_struct.h b/src/share/ob_rpc_struct.h index c9baf7ece..70035984d 100644 --- a/src/share/ob_rpc_struct.h +++ b/src/share/ob_rpc_struct.h @@ -2894,7 +2894,7 @@ public: uint64_t tenant_id_; uint64_t target_table_id_; int64_t schema_version_; - uint64_t execution_id_; + int64_t execution_id_; int64_t snapshot_version_; int64_t source_table_id_; int64_t task_id_; @@ -7187,7 +7187,7 @@ public: ObDDLBuildSingleReplicaRequestArg() : tenant_id_(OB_INVALID_ID), ls_id_(), source_tablet_id_(), dest_tablet_id_(), source_table_id_(OB_INVALID_ID), dest_schema_id_(OB_INVALID_ID), schema_version_(0), snapshot_version_(0), ddl_type_(0), task_id_(0), - parallelism_(0), execution_id_(0), tablet_task_id_(0) {} + parallelism_(0), execution_id_(-1), tablet_task_id_(0) {} bool is_valid() const { return OB_INVALID_ID != tenant_id_ && ls_id_.is_valid() && source_tablet_id_.is_valid() && dest_tablet_id_.is_valid() && OB_INVALID_ID != source_table_id_ && OB_INVALID_ID != dest_schema_id_ && schema_version_ > 0 && snapshot_version_ > 0 @@ -7233,12 +7233,12 @@ struct ObDDLBuildSingleReplicaResponseArg final public: ObDDLBuildSingleReplicaResponseArg() : tenant_id_(OB_INVALID_ID), ls_id_(), tablet_id_(), source_table_id_(), dest_schema_id_(OB_INVALID_ID), - ret_code_(OB_SUCCESS), snapshot_version_(0), schema_version_(0), task_id_(0), execution_id_(0) + ret_code_(OB_SUCCESS), snapshot_version_(0), schema_version_(0), task_id_(0), execution_id_(-1) {} ~ObDDLBuildSingleReplicaResponseArg() = default; bool is_valid() const { return OB_INVALID_ID != tenant_id_ && ls_id_.is_valid() && tablet_id_.is_valid() && OB_INVALID_ID != source_table_id_ && OB_INVALID_ID != dest_schema_id_ - && snapshot_version_ > 0 && schema_version_ > 0 && task_id_ > 0 && execution_id_ > 0; } + && snapshot_version_ > 0 && schema_version_ > 0 && task_id_ > 0 && execution_id_ >= 0; } int assign(const ObDDLBuildSingleReplicaResponseArg &other); TO_STRING_KV(K_(tenant_id), K_(ls_id), K_(tablet_id), K_(source_table_id), K_(dest_schema_id), K_(ret_code), K_(snapshot_version), K_(schema_version), K_(task_id), K_(execution_id)); public: @@ -7526,7 +7526,7 @@ public: bool is_valid() const { return tenant_id_ != OB_INVALID_ID && ls_id_.is_valid() && table_key_.is_valid() && start_scn_.is_valid_and_not_min() - && table_id_ > 0 && execution_id_ > 0 && ddl_task_id_ > 0; + && table_id_ > 0 && execution_id_ >= 0 && ddl_task_id_ > 0; } TO_STRING_KV(K_(tenant_id), K_(ls_id), K_(table_key), K_(start_scn), K_(table_id), K_(execution_id), K_(ddl_task_id)); diff --git a/src/sql/code_generator/ob_static_engine_cg.cpp b/src/sql/code_generator/ob_static_engine_cg.cpp index f28fd3cb3..107d68f6c 100644 --- a/src/sql/code_generator/ob_static_engine_cg.cpp +++ b/src/sql/code_generator/ob_static_engine_cg.cpp @@ -6000,7 +6000,7 @@ int ObStaticEngineCG::set_other_properties(const ObLogPlan &log_plan, ObPhysical if (log_plan.get_stmt()->get_table_items().count() > 0) { const TableItem *insert_table_item = log_plan.get_stmt()->get_table_item(0); if (nullptr != insert_table_item) { - int64_t ddl_execution_id = 0; + int64_t ddl_execution_id = -1; int64_t ddl_task_id = 0; const ObOptParamHint *opt_params = &log_plan.get_stmt()->get_query_ctx()->get_global_hint().opt_params_; OZ(opt_params->get_integer_opt_param(ObOptParamHint::DDL_EXECUTION_ID, ddl_execution_id)); diff --git a/src/sql/engine/ob_physical_plan.cpp b/src/sql/engine/ob_physical_plan.cpp index e567c3bf2..1b28f5f90 100644 --- a/src/sql/engine/ob_physical_plan.cpp +++ b/src/sql/engine/ob_physical_plan.cpp @@ -115,7 +115,7 @@ ObPhysicalPlan::ObPhysicalPlan(MemoryContext &mem_context /* = CURRENT_CONTEXT * contain_pl_udf_or_trigger_(false), ddl_schema_version_(0), ddl_table_id_(0), - ddl_execution_id_(0), + ddl_execution_id_(-1), ddl_task_id_(0), is_packed_(false), has_instead_of_trigger_(false) diff --git a/src/sql/resolver/dml/ob_hint.cpp b/src/sql/resolver/dml/ob_hint.cpp index 4c6f6604f..bd3dbebd4 100644 --- a/src/sql/resolver/dml/ob_hint.cpp +++ b/src/sql/resolver/dml/ob_hint.cpp @@ -601,7 +601,7 @@ bool ObOptParamHint::is_param_val_valid(const OptParamType param_type, const ObO break; } case DDL_EXECUTION_ID: { - is_valid = val.is_int() && (0 < val.get_int()); + is_valid = val.is_int() && (0 <= val.get_int()); break; } case DDL_TASK_ID: { diff --git a/src/storage/ddl/ob_build_index_task.cpp b/src/storage/ddl/ob_build_index_task.cpp index 3be258d98..2f0fbf87a 100644 --- a/src/storage/ddl/ob_build_index_task.cpp +++ b/src/storage/ddl/ob_build_index_task.cpp @@ -41,7 +41,7 @@ using namespace oceanbase::palf; ObUniqueIndexChecker::ObUniqueIndexChecker() : is_inited_(false), tenant_id_(OB_INVALID_TENANT_ID), ls_id_(), tablet_id_(), - index_schema_(NULL), data_table_schema_(NULL), execution_id_(0), snapshot_version_(0), task_id_(0), + index_schema_(NULL), data_table_schema_(NULL), execution_id_(-1), snapshot_version_(0), task_id_(0), is_scan_index_(false) { } @@ -54,7 +54,7 @@ int ObUniqueIndexChecker::init( const ObTableSchema *data_table_schema, const ObTableSchema *index_schema, const int64_t task_id, - const uint64_t execution_id, + const int64_t execution_id, const int64_t snapshot_version) { int ret = OB_SUCCESS; @@ -593,7 +593,7 @@ int ObUniqueIndexChecker::wait_trans_end(ObIDag *dag) ObUniqueCheckingDag::ObUniqueCheckingDag() : ObIDag(ObDagType::DAG_TYPE_UNIQUE_CHECKING), is_inited_(false), tenant_id_(OB_INVALID_TENANT_ID), tablet_id_(), is_scan_index_(false), schema_guard_(share::schema::ObSchemaMgrItem::MOD_UNIQ_CHECK), index_schema_(nullptr), data_table_schema_(nullptr), callback_(nullptr), - execution_id_(0), snapshot_version_(0), compat_mode_(lib::Worker::CompatMode::INVALID) + execution_id_(-1), snapshot_version_(0), compat_mode_(lib::Worker::CompatMode::INVALID) { } @@ -613,7 +613,7 @@ int ObUniqueCheckingDag::init( const uint64_t index_table_id, const int64_t schema_version, const int64_t task_id, - const uint64_t execution_id, + const int64_t execution_id, const int64_t snapshot_version) { int ret = OB_SUCCESS; diff --git a/src/storage/ddl/ob_build_index_task.h b/src/storage/ddl/ob_build_index_task.h index 4707ac9e4..067d1fc55 100644 --- a/src/storage/ddl/ob_build_index_task.h +++ b/src/storage/ddl/ob_build_index_task.h @@ -38,7 +38,7 @@ public: const share::schema::ObTableSchema *data_table_schema, const share::schema::ObTableSchema *index_schema, const int64_t task_id, - const uint64_t execution_id = OB_INVALID_ID, + const int64_t execution_id = -1, const int64_t snapshot_version = OB_INVALID_VERSION); int check_unique_index(share::ObIDag *dag); private: @@ -109,7 +109,7 @@ private: common::ObTabletID tablet_id_; const share::schema::ObTableSchema *index_schema_; const share::schema::ObTableSchema *data_table_schema_; - uint64_t execution_id_; + int64_t execution_id_; int64_t snapshot_version_; int64_t task_id_; ObTabletHandle tablet_handle_; @@ -159,11 +159,11 @@ public: const bool is_scan_index, const uint64_t index_table_id, const int64_t schema_version, const int64_t task_id, - const uint64_t execution_id = OB_INVALID_ID, + const int64_t execution_id = -1, const int64_t snapshot_version = OB_INVALID_VERSION); const share::schema::ObTableSchema *get_index_schema() const { return index_schema_; } const share::schema::ObTableSchema *get_data_table_schema() const { return data_table_schema_; } - uint64_t get_execution_id() const { return execution_id_; } + int64_t get_execution_id() const { return execution_id_; } int64_t get_snapshot_version() const { return snapshot_version_; } int64_t get_task_id() const { return task_id_; } bool get_is_scan_index() const { return is_scan_index_; } @@ -194,7 +194,7 @@ private: const share::schema::ObTableSchema *index_schema_; const share::schema::ObTableSchema *data_table_schema_; ObIUniqueCheckingCompleteCallback *callback_; - uint64_t execution_id_; + int64_t execution_id_; int64_t snapshot_version_; int64_t task_id_; lib::Worker::CompatMode compat_mode_; diff --git a/src/storage/ddl/ob_complement_data_task.h b/src/storage/ddl/ob_complement_data_task.h index b00b14e9e..979e38853 100644 --- a/src/storage/ddl/ob_complement_data_task.h +++ b/src/storage/ddl/ob_complement_data_task.h @@ -42,7 +42,7 @@ public: source_tablet_id_(ObTabletID::INVALID_TABLET_ID), dest_tablet_id_(ObTabletID::INVALID_TABLET_ID), data_table_schema_(nullptr), hidden_table_schema_(nullptr), allocator_("CompleteDataPar"), row_store_type_(common::ENCODING_ROW_STORE), schema_version_(0), snapshot_version_(0), - concurrent_cnt_(0), task_id_(0), execution_id_(0), tablet_task_id_(0), + concurrent_cnt_(0), task_id_(0), execution_id_(-1), tablet_task_id_(0), compat_mode_(lib::Worker::CompatMode::INVALID) {} ~ObComplementDataParam() { destroy(); } @@ -54,7 +54,7 @@ public: return common::OB_INVALID_TENANT_ID != tenant_id_ && ls_id_.is_valid() && source_tablet_id_.is_valid() && dest_tablet_id_.is_valid() && OB_NOT_NULL(data_table_schema_) && OB_NOT_NULL(hidden_table_schema_) && 0 != concurrent_cnt_ && snapshot_version_ > 0 && compat_mode_ != lib::Worker::CompatMode::INVALID - && execution_id_ > 0 && tablet_task_id_ > 0; + && execution_id_ >= 0 && tablet_task_id_ > 0; } int get_hidden_table_key(ObITable::TableKey &table_key) const; void destroy() @@ -79,7 +79,7 @@ public: snapshot_version_ = 0; concurrent_cnt_ = 0; task_id_ = 0; - execution_id_ = 0; + execution_id_ = -1; tablet_task_id_ = 0; compat_mode_ = lib::Worker::CompatMode::INVALID; } diff --git a/src/storage/ddl/ob_ddl_clog.cpp b/src/storage/ddl/ob_ddl_clog.cpp index aec087745..4cd9850e3 100644 --- a/src/storage/ddl/ob_ddl_clog.cpp +++ b/src/storage/ddl/ob_ddl_clog.cpp @@ -265,7 +265,7 @@ DEFINE_GET_SERIALIZE_SIZE(ObDDLClogHeader) } ObDDLStartLog::ObDDLStartLog() - : table_key_(), cluster_version_(0), execution_id_(0) + : table_key_(), cluster_version_(0), execution_id_(-1) { } diff --git a/src/storage/ddl/ob_ddl_merge_task.cpp b/src/storage/ddl/ob_ddl_merge_task.cpp index 7488e2a9d..9885566be 100644 --- a/src/storage/ddl/ob_ddl_merge_task.cpp +++ b/src/storage/ddl/ob_ddl_merge_task.cpp @@ -403,7 +403,7 @@ int ObDDLTableMergeTask::process() 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 + && merge_param_.execution_id_ >= 0 && OB_FAIL(ObTabletDDLUtil::report_ddl_checksum(merge_param_.ls_id_, merge_param_.tablet_id_, merge_param_.table_id_, @@ -777,7 +777,7 @@ int ObTabletDDLUtil::report_ddl_checksum(const share::ObLSID &ls_id, const ObTableSchema *table_schema = nullptr; const uint64_t tenant_id = MTL_ID(); if (OB_UNLIKELY(!ls_id.is_valid() || !tablet_id.is_valid() || OB_INVALID_ID == ddl_task_id - || !is_valid_id(table_id) || 0 == table_id || execution_id <= 0)) { + || !is_valid_id(table_id) || 0 == table_id || execution_id < 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(ls_id), K(tablet_id), K(table_id), K(execution_id)); } else if (!is_valid_tenant_id(tenant_id) || OB_ISNULL(sql_proxy) || OB_ISNULL(schema_service)) { diff --git a/src/storage/ddl/ob_ddl_merge_task.h b/src/storage/ddl/ob_ddl_merge_task.h index f3bd61bca..6786db8f9 100644 --- a/src/storage/ddl/ob_ddl_merge_task.h +++ b/src/storage/ddl/ob_ddl_merge_task.h @@ -46,7 +46,7 @@ public: is_commit_(false), start_scn_(share::SCN::min_scn()), table_id_(0), - execution_id_(0), + execution_id_(-1), ddl_task_id_(0) { } bool is_valid() const diff --git a/src/storage/ddl/ob_ddl_redo_log_writer.cpp b/src/storage/ddl/ob_ddl_redo_log_writer.cpp index 52c5e6dee..638865aa3 100644 --- a/src/storage/ddl/ob_ddl_redo_log_writer.cpp +++ b/src/storage/ddl/ob_ddl_redo_log_writer.cpp @@ -972,7 +972,7 @@ int ObDDLSSTableRedoWriter::start_ddl_redo(const ObITable::TableKey &table_key, if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("ObDDLSSTableRedoWriter has not been inited", K(ret)); - } else if (OB_UNLIKELY(!table_key.is_valid() || execution_id <= 0)) { + } else if (OB_UNLIKELY(!table_key.is_valid() || execution_id < 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arguments", K(ret), K(table_key), K(execution_id)); } else if (OB_FAIL(log.init(table_key, GET_MIN_CLUSTER_VERSION(), execution_id))) { diff --git a/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp b/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp index f64ed4c6b..793ae0f50 100644 --- a/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp +++ b/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp @@ -38,7 +38,7 @@ using namespace oceanbase::sql; /*************** ObSSTableInsertTabletParam *****************/ ObSSTableInsertTabletParam::ObSSTableInsertTabletParam() : context_id_(0), ls_id_(), tablet_id_(), table_id_(0), write_major_(false), - task_cnt_(0), schema_version_(0), snapshot_version_(0), execution_id_(0), ddl_task_id_(0) + task_cnt_(0), schema_version_(0), snapshot_version_(0), execution_id_(-1), ddl_task_id_(0) { } @@ -56,7 +56,7 @@ bool ObSSTableInsertTabletParam::is_valid() const && table_id_ > 0 && task_cnt_ >= 0 && schema_version_ > 0 - && execution_id_ > 0 + && execution_id_ >= 0 && ddl_task_id_ > 0; return bret; } @@ -735,7 +735,7 @@ int ObSSTableInsertTabletContext::get_table_key(ObITable::TableKey &table_key) ObSSTableInsertTableParam::ObSSTableInsertTableParam() : exec_ctx_(nullptr), context_id_(0), dest_table_id_(OB_INVALID_ID), write_major_(false), schema_version_(0), - snapshot_version_(0), task_cnt_(0), execution_id_(0), ddl_task_id_(0), ls_tablet_ids_() + snapshot_version_(0), task_cnt_(0), execution_id_(-1), ddl_task_id_(0), ls_tablet_ids_() { } diff --git a/src/storage/ddl/ob_direct_insert_sstable_ctx.h b/src/storage/ddl/ob_direct_insert_sstable_ctx.h index 5ac4cbff9..91858a52a 100644 --- a/src/storage/ddl/ob_direct_insert_sstable_ctx.h +++ b/src/storage/ddl/ob_direct_insert_sstable_ctx.h @@ -148,7 +148,7 @@ public: int assign(const ObSSTableInsertTableParam &other); bool is_valid() const { return exec_ctx_ != nullptr && OB_INVALID_ID != dest_table_id_ && schema_version_ >= 0 && snapshot_version_ >= 0 && task_cnt_ >= 0 - && execution_id_ > 0 && ddl_task_id_ > 0 && ls_tablet_ids_.count() > 0; } + && execution_id_ >= 0 && ddl_task_id_ > 0 && ls_tablet_ids_.count() > 0; } TO_STRING_KV(K_(context_id), K_(dest_table_id), K_(write_major), K_(schema_version), K_(snapshot_version), K_(task_cnt), K_(execution_id), K_(ddl_task_id), K_(ls_tablet_ids)); public: diff --git a/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp b/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp index cb3b68639..e01d4e17d 100644 --- a/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp +++ b/src/storage/ddl/ob_tablet_ddl_kv_mgr.cpp @@ -30,7 +30,7 @@ using namespace oceanbase::storage; ObTabletDDLKvMgr::ObTabletDDLKvMgr() : is_inited_(false), success_start_scn_(SCN::min_scn()), ls_id_(), tablet_id_(), table_key_(), cluster_version_(0), start_scn_(SCN::min_scn()), max_freeze_scn_(SCN::min_scn()), - table_id_(0), execution_id_(0), head_(0), tail_(0), lock_(ObLatchIds::TABLET_DDL_KV_MGR_LOCK), ref_cnt_(0) + table_id_(0), execution_id_(-1), head_(0), tail_(0), lock_(ObLatchIds::TABLET_DDL_KV_MGR_LOCK), ref_cnt_(0) { MEMSET(ddl_kvs_, 0, MAX_DDL_KV_CNT_IN_STORAGE * sizeof(ddl_kvs_[0])); } @@ -61,7 +61,7 @@ void ObTabletDDLKvMgr::destroy() start_scn_.set_min(); max_freeze_scn_.set_min(); table_id_ = 0; - execution_id_ = 0; + execution_id_ = -1; success_start_scn_.set_min(); is_inited_ = false; } @@ -345,7 +345,7 @@ void ObTabletDDLKvMgr::cleanup_unlock() start_scn_.set_min(); max_freeze_scn_.set_min(); table_id_ = 0; - execution_id_ = 0; + execution_id_ = -1; success_start_scn_.set_min(); } diff --git a/src/storage/ob_storage_struct.cpp b/src/storage/ob_storage_struct.cpp index 9882bfacd..436b630be 100644 --- a/src/storage/ob_storage_struct.cpp +++ b/src/storage/ob_storage_struct.cpp @@ -222,7 +222,7 @@ ObUpdateTableStoreParam::ObUpdateTableStoreParam( ddl_checkpoint_scn_(SCN::min_scn()), ddl_start_scn_(SCN::min_scn()), ddl_snapshot_version_(0), - ddl_execution_id_(0), + ddl_execution_id_(-1), ddl_cluster_version_(0), allow_duplicate_sstable_(false), tx_data_(), @@ -255,7 +255,7 @@ ObUpdateTableStoreParam::ObUpdateTableStoreParam( ddl_checkpoint_scn_(SCN::min_scn()), ddl_start_scn_(SCN::min_scn()), ddl_snapshot_version_(0), - ddl_execution_id_(0), + ddl_execution_id_(-1), ddl_cluster_version_(0), allow_duplicate_sstable_(allow_duplicate_sstable), tx_data_(), @@ -286,7 +286,7 @@ ObUpdateTableStoreParam::ObUpdateTableStoreParam( ddl_checkpoint_scn_(SCN::min_scn()), ddl_start_scn_(SCN::min_scn()), ddl_snapshot_version_(0), - ddl_execution_id_(0), + ddl_execution_id_(-1), ddl_cluster_version_(0), allow_duplicate_sstable_(false), tx_data_(), diff --git a/src/storage/tablet/ob_tablet_meta.cpp b/src/storage/tablet/ob_tablet_meta.cpp index ab510de4b..4380f37b7 100644 --- a/src/storage/tablet/ob_tablet_meta.cpp +++ b/src/storage/tablet/ob_tablet_meta.cpp @@ -56,7 +56,7 @@ ObTabletMeta::ObTabletMeta() ddl_start_scn_(SCN::min_scn()), ddl_snapshot_version_(OB_INVALID_TIMESTAMP), max_sync_storage_schema_version_(0), - ddl_execution_id_(0), + ddl_execution_id_(-1), ddl_cluster_version_(0), is_inited_(false) { @@ -113,7 +113,7 @@ int ObTabletMeta::init( ddl_start_scn_.set_min(); ddl_snapshot_version_ = 0; max_sync_storage_schema_version_ = max_sync_storage_schema_version; - ddl_execution_id_ = 0; + ddl_execution_id_ = -1; ddl_cluster_version_ = 0; report_status_.merge_snapshot_version_ = snapshot_version; @@ -356,7 +356,7 @@ void ObTabletMeta::reset() ddl_start_scn_.set_min(); ddl_snapshot_version_ = OB_INVALID_TIMESTAMP; max_sync_storage_schema_version_ = 0; - ddl_execution_id_ = 0; + ddl_execution_id_ = -1; ddl_cluster_version_ = 0; is_inited_ = false; } @@ -745,7 +745,7 @@ ObMigrationTabletParam::ObMigrationTabletParam() ddl_start_scn_(SCN::min_scn()), ddl_snapshot_version_(OB_INVALID_TIMESTAMP), max_sync_storage_schema_version_(0), - ddl_execution_id_(0), + ddl_execution_id_(-1), ddl_cluster_version_(0) { } @@ -958,7 +958,7 @@ void ObMigrationTabletParam::reset() ddl_start_scn_.set_min(); ddl_snapshot_version_ = OB_INVALID_TIMESTAMP; max_sync_storage_schema_version_ = 0; - ddl_execution_id_ = 0; + ddl_execution_id_ = -1; ddl_cluster_version_ = 0; } diff --git a/src/storage/tablet/ob_tablet_meta.h b/src/storage/tablet/ob_tablet_meta.h index b8d83e9e8..342893e61 100644 --- a/src/storage/tablet/ob_tablet_meta.h +++ b/src/storage/tablet/ob_tablet_meta.h @@ -78,7 +78,7 @@ public: const share::SCN ddl_checkpoint_scn = share::SCN::min_scn(), const share::SCN ddl_start_scn = share::SCN::min_scn(), const int64_t ddl_snapshot_version = 0, - const int64_t ddl_execution_id = 0, + const int64_t ddl_execution_id = -1, const int64_t ddl_cluster_version = 0); int init( common::ObIAllocator &allocator,