From 240d3685c65da04eff7e6a5daa90528940193627 Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 24 Apr 2023 02:44:38 +0000 Subject: [PATCH] fix longops start time not correct --- deps/easy/src/io/easy_negotiation.c | 18 +++++++++--------- .../ddl_task/ob_column_redefinition_task.cpp | 1 + src/rootserver/ddl_task/ob_constraint_task.cpp | 1 + src/rootserver/ddl_task/ob_ddl_retry_task.cpp | 1 + src/rootserver/ddl_task/ob_ddl_task.cpp | 10 ++++++---- src/rootserver/ddl_task/ob_ddl_task.h | 2 +- src/rootserver/ddl_task/ob_drop_index_task.cpp | 1 + .../ddl_task/ob_drop_primary_key_task.cpp | 1 + .../ddl_task/ob_index_build_task.cpp | 1 + .../ddl_task/ob_modify_autoinc_task.cpp | 1 + .../ddl_task/ob_table_redefinition_task.cpp | 1 + 11 files changed, 24 insertions(+), 14 deletions(-) diff --git a/deps/easy/src/io/easy_negotiation.c b/deps/easy/src/io/easy_negotiation.c index 264b87b21..479cb22eb 100644 --- a/deps/easy/src/io/easy_negotiation.c +++ b/deps/easy/src/io/easy_negotiation.c @@ -64,9 +64,9 @@ static int easy_encode_uint16(char *buf, const uint64_t buf_len, int64_t *pos, u { int ret = ((NULL != buf) && ((buf_len - *pos) >= (uint64_t)(sizeof(val)))) ? EASY_OK : EASY_ABORT; - - if (EASY_OK == ret) { - *(buf + (*pos)++) = (char)((((val) >> 8)) & 0xff); + + if (EASY_OK == ret) { + *(buf + (*pos)++) = (char)((((val) >> 8)) & 0xff); *(buf + (*pos)++) = (char)((val) & 0xff); } @@ -164,9 +164,9 @@ static int easy_decode_negotiation_msg(easy_negotiation_msg_t *ne_msg, char *rec easy_info_log("decode eio magic failed!ret:%d.", ret); return ret; } - - pos++; //for io thread index - *decode_len = pos; + + pos++; //for io thread index + *decode_len = pos; return ret; } @@ -276,9 +276,9 @@ void net_consume_negotiation_msg(int fd, uint64_t magic) return; } - -int easy_send_negotiate_message(easy_connection_t *c) -{ + +int easy_send_negotiate_message(easy_connection_t *c) +{ int ret = EASY_OK; easy_io_thread_t *ioth = c->ioth; easy_io_t *eio = ioth->eio; diff --git a/src/rootserver/ddl_task/ob_column_redefinition_task.cpp b/src/rootserver/ddl_task/ob_column_redefinition_task.cpp index 4df44ab52..d922d441b 100644 --- a/src/rootserver/ddl_task/ob_column_redefinition_task.cpp +++ b/src/rootserver/ddl_task/ob_column_redefinition_task.cpp @@ -59,6 +59,7 @@ int ObColumnRedefinitionTask::init(const uint64_t tenant_id, const int64_t task_ } else if (OB_FAIL(ObShareUtil::fetch_current_data_version(*GCTX.sql_proxy_, tenant_id, tenant_data_format_version))) { LOG_WARN("get min data version failed", K(ret), K(tenant_id)); } else { + set_gmt_create(ObTimeUtility::current_time()); task_type_ = ddl_type; object_id_ = data_table_id; target_object_id_ = dest_table_id; diff --git a/src/rootserver/ddl_task/ob_constraint_task.cpp b/src/rootserver/ddl_task/ob_constraint_task.cpp index 3ed9d816e..f2e512b94 100644 --- a/src/rootserver/ddl_task/ob_constraint_task.cpp +++ b/src/rootserver/ddl_task/ob_constraint_task.cpp @@ -507,6 +507,7 @@ int ObConstraintTask::init( ret = OB_ERR_SYS; LOG_WARN("error sys, root service must not be nullptr", K(ret)); } else { + set_gmt_create(ObTimeUtility::current_time()); object_id_ = table_schema->get_table_id(); target_object_id_ = object_id; tenant_id_ = tenant_id; diff --git a/src/rootserver/ddl_task/ob_ddl_retry_task.cpp b/src/rootserver/ddl_task/ob_ddl_retry_task.cpp index 4bba74cda..811771160 100644 --- a/src/rootserver/ddl_task/ob_ddl_retry_task.cpp +++ b/src/rootserver/ddl_task/ob_ddl_retry_task.cpp @@ -179,6 +179,7 @@ int ObDDLRetryTask::init(const uint64_t tenant_id, } else if (OB_FAIL(init_compat_mode(ddl_type, ddl_arg))) { LOG_WARN("init compat mode failed", K(ret)); } else { + set_gmt_create(ObTimeUtility::current_time()); object_id_ = object_id; target_object_id_ = object_id; schema_version_ = schema_version; diff --git a/src/rootserver/ddl_task/ob_ddl_task.cpp b/src/rootserver/ddl_task/ob_ddl_task.cpp index 47d638154..ff2a6d54d 100644 --- a/src/rootserver/ddl_task/ob_ddl_task.cpp +++ b/src/rootserver/ddl_task/ob_ddl_task.cpp @@ -863,6 +863,7 @@ int ObDDLTask::convert_to_record( int ret = OB_SUCCESS; const int64_t serialize_param_size = get_serialize_param_size(); int64_t pos = 0; + task_record.gmt_create_ = get_gmt_create(); task_record.tenant_id_ = get_tenant_id(); task_record.object_id_ = get_object_id(); task_record.target_object_id_ = get_target_object_id(); @@ -1282,7 +1283,7 @@ int ObDDLTask::copy_longops_stat(ObLongopsValue &value) value.tenant_id_ = tenant_id_; value.start_time_ = gmt_create_; value.finish_time_ = stat_info_.finish_time_; - value.elapsed_seconds_ = (ObTimeUtility::current_time() - stat_info_.start_time_); + value.elapsed_seconds_ = (ObTimeUtility::current_time() - value.start_time_); value.time_remaining_ = stat_info_.time_remaining_; value.last_update_time_ = ObTimeUtility::current_time(); MEMCPY(value.op_name_, stat_info_.op_name_, common::MAX_LONG_OPS_NAME_LENGTH); @@ -2442,6 +2443,7 @@ bool ObDDLTaskRecord::is_valid() const void ObDDLTaskRecord::reset() { + gmt_create_ = 0; task_id_ = 0; parent_task_id_ = 0; ddl_type_ = ObDDLType::DDL_INVALID; @@ -2988,9 +2990,9 @@ int ObDDLTaskRecordOperator::insert_record( } else if (OB_FAIL(to_hex_str(record.message_, message_string))) { 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, %ld, %lu, '%.*s', \"%.*s\") ", - OB_ALL_DDL_TASK_STATUS_TNAME, record.task_id_, record.parent_task_id_, + " INSERT INTO %s (gmt_create, gmt_modified, 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 (usec_to_time(%lu), usec_to_time(%lu), %lu, %lu, %lu, %lu, %lu, %lu, %d, '%s', %ld, %lu, %ld, %lu, '%.*s', \"%.*s\") ", + OB_ALL_DDL_TASK_STATUS_TNAME, record.gmt_create_, record.gmt_create_, 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_, static_cast(ddl_stmt_string.length()), ddl_stmt_string.ptr(), static_cast(message_string.length()), message_string.ptr()))) { diff --git a/src/rootserver/ddl_task/ob_ddl_task.h b/src/rootserver/ddl_task/ob_ddl_task.h index 6ad3dba0f..64ce6e380 100644 --- a/src/rootserver/ddl_task/ob_ddl_task.h +++ b/src/rootserver/ddl_task/ob_ddl_task.h @@ -432,7 +432,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), - longops_stat_(nullptr), stat_info_(), delay_schedule_time_(0), next_schedule_ts_(0), + longops_stat_(nullptr), gmt_create_(0), stat_info_(), delay_schedule_time_(0), next_schedule_ts_(0), execution_id_(-1), sql_exec_addr_(), start_time_(0), data_format_version_(0) {} virtual ~ObDDLTask() {} diff --git a/src/rootserver/ddl_task/ob_drop_index_task.cpp b/src/rootserver/ddl_task/ob_drop_index_task.cpp index 39493d075..07cdb4964 100644 --- a/src/rootserver/ddl_task/ob_drop_index_task.cpp +++ b/src/rootserver/ddl_task/ob_drop_index_task.cpp @@ -56,6 +56,7 @@ int ObDropIndexTask::init( } else if (OB_FAIL(deep_copy_index_arg(allocator_, drop_index_arg, drop_index_arg_))) { LOG_WARN("deep copy drop index arg failed", K(ret)); } else { + set_gmt_create(ObTimeUtility::current_time()); tenant_id_ = tenant_id; object_id_ = data_table_id; target_object_id_ = index_table_id; diff --git a/src/rootserver/ddl_task/ob_drop_primary_key_task.cpp b/src/rootserver/ddl_task/ob_drop_primary_key_task.cpp index 1469e9523..d510b8e68 100644 --- a/src/rootserver/ddl_task/ob_drop_primary_key_task.cpp +++ b/src/rootserver/ddl_task/ob_drop_primary_key_task.cpp @@ -48,6 +48,7 @@ int ObDropPrimaryKeyTask::init(const uint64_t tenant_id, const int64_t task_id, alter_table_arg, task_status, snapshot_version))) { LOG_WARN("fail to init ObDropPrimaryKeyTask", K(ret)); } else { + set_gmt_create(ObTimeUtility::current_time()); consumer_group_id_ = consumer_group_id; task_version_ = OB_DROP_PRIMARY_KEY_TASK_VERSION; ddl_tracing_.open(); diff --git a/src/rootserver/ddl_task/ob_index_build_task.cpp b/src/rootserver/ddl_task/ob_index_build_task.cpp index afb6677ab..2e303f159 100644 --- a/src/rootserver/ddl_task/ob_index_build_task.cpp +++ b/src/rootserver/ddl_task/ob_index_build_task.cpp @@ -351,6 +351,7 @@ int ObIndexBuildTask::init( } else if (OB_FAIL(ObShareUtil::fetch_current_data_version(*GCTX.sql_proxy_, tenant_id, tenant_data_format_version))) { LOG_WARN("get min data version failed", K(ret), K(tenant_id)); } else { + set_gmt_create(ObTimeUtility::current_time()); is_global_index_ = index_schema->is_global_index_table(); is_unique_index_ = index_schema->is_unique_index(); tenant_id_ = tenant_id; diff --git a/src/rootserver/ddl_task/ob_modify_autoinc_task.cpp b/src/rootserver/ddl_task/ob_modify_autoinc_task.cpp index fcd69764b..7881dd733 100644 --- a/src/rootserver/ddl_task/ob_modify_autoinc_task.cpp +++ b/src/rootserver/ddl_task/ob_modify_autoinc_task.cpp @@ -171,6 +171,7 @@ int ObModifyAutoincTask::init(const uint64_t tenant_id, } else if (OB_FAIL(set_ddl_stmt_str(alter_table_arg_.ddl_stmt_str_))) { LOG_WARN("set ddl stmt str failed", K(ret)); } else { + set_gmt_create(ObTimeUtility::current_time()); task_type_ = ObDDLType::DDL_MODIFY_AUTO_INCREMENT; object_id_ = table_id; target_object_id_ = table_id; diff --git a/src/rootserver/ddl_task/ob_table_redefinition_task.cpp b/src/rootserver/ddl_task/ob_table_redefinition_task.cpp index 427d01726..323c28d1b 100644 --- a/src/rootserver/ddl_task/ob_table_redefinition_task.cpp +++ b/src/rootserver/ddl_task/ob_table_redefinition_task.cpp @@ -63,6 +63,7 @@ int ObTableRedefinitionTask::init(const uint64_t tenant_id, const int64_t task_i } else if (OB_FAIL(ObShareUtil::fetch_current_data_version(*GCTX.sql_proxy_, tenant_id, tenant_data_format_version))) { LOG_WARN("get min data version failed", K(ret), K(tenant_id)); } else { + set_gmt_create(ObTimeUtility::current_time()); consumer_group_id_ = consumer_group_id; task_type_ = ddl_type; object_id_ = data_table_id;