From 83a2af836983c55f6bdd94f6031ac11156818c4c Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 11 Jul 2024 10:06:27 +0000 Subject: [PATCH] placeholder for lock table --- src/share/ob_rpc_struct.cpp | 154 +++++++++--------- src/share/ob_rpc_struct.h | 24 ++- src/storage/tablelock/ob_table_lock_common.h | 8 + .../tablelock/ob_table_lock_rpc_struct.cpp | 15 +- .../tablelock/ob_table_lock_rpc_struct.h | 16 +- 5 files changed, 134 insertions(+), 83 deletions(-) diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index 25e8220a9..6f25ca1f8 100644 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -2486,32 +2486,31 @@ OB_DEF_SERIALIZE(ObAlterTableArg) } } LST_DO_CODE(OB_UNIS_ENCODE, - ddl_task_type_, - compat_mode_, - table_id_, - hidden_table_id_, - is_alter_columns_, - is_alter_indexs_, - is_alter_options_, - is_alter_partitions_, - is_inner_, - is_update_global_indexes_, - is_convert_to_character_, - skip_sys_table_check_, - need_rebuild_trigger_, - foreign_key_checks_, - is_add_to_scheduler_, - inner_sql_exec_addr_, - local_session_var_, - mview_refresh_info_, - alter_algorithm_, - alter_auto_partition_attr_); + ddl_task_type_, + compat_mode_, + table_id_, + hidden_table_id_, + is_alter_columns_, + is_alter_indexs_, + is_alter_options_, + is_alter_partitions_, + is_inner_, + is_update_global_indexes_, + is_convert_to_character_, + skip_sys_table_check_, + need_rebuild_trigger_, + foreign_key_checks_, + is_add_to_scheduler_, + inner_sql_exec_addr_, + local_session_var_, + mview_refresh_info_, + alter_algorithm_, + alter_auto_partition_attr_, + rebuild_index_arg_list_, + client_session_id_, + client_session_create_ts_, + lock_priority_); - if (OB_SUCC(ret)) { - if (OB_FAIL(rebuild_index_arg_list_.serialize(buf, buf_len, pos))) { - SHARE_SCHEMA_LOG(WARN, "fail to serialize rebuild_index_arg_list_", K(ret)); - } - } return ret; } @@ -2584,32 +2583,30 @@ OB_DEF_DESERIALIZE(ObAlterTableArg) } } LST_DO_CODE(OB_UNIS_DECODE, - ddl_task_type_, - compat_mode_, - table_id_, - hidden_table_id_, - is_alter_columns_, - is_alter_indexs_, - is_alter_options_, - is_alter_partitions_, - is_inner_, - is_update_global_indexes_, - is_convert_to_character_, - skip_sys_table_check_, - need_rebuild_trigger_, - foreign_key_checks_, - is_add_to_scheduler_, - inner_sql_exec_addr_, - local_session_var_, - mview_refresh_info_, - alter_algorithm_, - alter_auto_partition_attr_); - - if (OB_SUCC(ret) && pos < data_len) { - if (OB_FAIL(rebuild_index_arg_list_.deserialize(buf, data_len, pos))) { - SHARE_SCHEMA_LOG(WARN, "fail to deserialize rebuild_index_arg_list_", K(ret)); - } - } + ddl_task_type_, + compat_mode_, + table_id_, + hidden_table_id_, + is_alter_columns_, + is_alter_indexs_, + is_alter_options_, + is_alter_partitions_, + is_inner_, + is_update_global_indexes_, + is_convert_to_character_, + skip_sys_table_check_, + need_rebuild_trigger_, + foreign_key_checks_, + is_add_to_scheduler_, + inner_sql_exec_addr_, + local_session_var_, + mview_refresh_info_, + alter_algorithm_, + alter_auto_partition_attr_, + rebuild_index_arg_list_, + client_session_id_, + client_session_create_ts_, + lock_priority_); return ret; } @@ -2633,30 +2630,33 @@ OB_DEF_SERIALIZE_SIZE(ObAlterTableArg) len += nls_formats_[i].get_serialize_size(); } len += foreign_key_arg_list_.get_serialize_size(); - len += rebuild_index_arg_list_.get_serialize_size(); len += sequence_ddl_arg_.get_serialize_size(); len += serialization::encoded_length_i64(sql_mode_); LST_DO_CODE(OB_UNIS_ADD_LEN, - ddl_task_type_, - compat_mode_, - table_id_, - hidden_table_id_, - is_alter_columns_, - is_alter_indexs_, - is_alter_options_, - is_alter_partitions_, - is_inner_, - is_update_global_indexes_, - is_convert_to_character_, - skip_sys_table_check_, - need_rebuild_trigger_, - foreign_key_checks_, - is_add_to_scheduler_, - inner_sql_exec_addr_, - local_session_var_, - mview_refresh_info_, - alter_algorithm_, - alter_auto_partition_attr_); + ddl_task_type_, + compat_mode_, + table_id_, + hidden_table_id_, + is_alter_columns_, + is_alter_indexs_, + is_alter_options_, + is_alter_partitions_, + is_inner_, + is_update_global_indexes_, + is_convert_to_character_, + skip_sys_table_check_, + need_rebuild_trigger_, + foreign_key_checks_, + is_add_to_scheduler_, + inner_sql_exec_addr_, + local_session_var_, + mview_refresh_info_, + alter_algorithm_, + alter_auto_partition_attr_, + rebuild_index_arg_list_, + client_session_id_, + client_session_create_ts_, + lock_priority_); } if (OB_FAIL(ret)) { @@ -2824,14 +2824,20 @@ DEF_TO_STRING(ObRenameTableArg) int64_t pos = 0; J_OBJ_START(); J_KV(K_(tenant_id), - K_(rename_table_items)); + K_(rename_table_items), + K_(client_session_id), + K_(client_session_create_ts), + K_(lock_priority)); J_OBJ_END(); return pos; } OB_SERIALIZE_MEMBER((ObRenameTableArg, ObDDLArg), tenant_id_, - rename_table_items_); + rename_table_items_, + client_session_id_, + client_session_create_ts_, + lock_priority_); DEF_TO_STRING(ObTableItem) { diff --git a/src/share/ob_rpc_struct.h b/src/share/ob_rpc_struct.h index 1f445517f..5859806a3 100644 --- a/src/share/ob_rpc_struct.h +++ b/src/share/ob_rpc_struct.h @@ -79,6 +79,8 @@ #include "share/location_cache/ob_location_update_task.h" #include "share/resource_limit_calculator/ob_resource_limit_calculator.h"//ObUserResourceCalculateArg #include "share/ob_heartbeat_handler.h" +#include "storage/tablelock/ob_table_lock_common.h" //ObTableLockPriority + namespace oceanbase { namespace rootserver @@ -1610,13 +1612,19 @@ public: ObRenameTableArg(): ObDDLArg(), tenant_id_(common::OB_INVALID_ID), - rename_table_items_() + rename_table_items_(), + client_session_id_(0), + client_session_create_ts_(0), + lock_priority_(transaction::tablelock::ObTableLockPriority::NORMAL) {} bool is_valid() const; DECLARE_TO_STRING; uint64_t tenant_id_; common::ObSArray rename_table_items_; + uint32_t client_session_id_; + int64_t client_session_create_ts_; + transaction::tablelock::ObTableLockPriority lock_priority_; }; struct ObStartRedefTableArg final { @@ -2160,7 +2168,10 @@ public: mview_refresh_info_(), alter_algorithm_(INPLACE), alter_auto_partition_attr_(false), - rebuild_index_arg_list_() + rebuild_index_arg_list_(), + client_session_id_(0), + client_session_create_ts_(0), + lock_priority_(transaction::tablelock::ObTableLockPriority::NORMAL) { } virtual ~ObAlterTableArg() @@ -2229,7 +2240,11 @@ public: K_(inner_sql_exec_addr), K_(local_session_var), K_(mview_refresh_info), - K_(alter_algorithm)); + K_(alter_algorithm), + K_(alter_auto_partition_attr), + K_(client_session_id), + K_(client_session_create_ts), + K_(lock_priority)); private: int alloc_index_arg(const ObIndexArg::IndexActionType index_action_type, ObIndexArg *&index_arg); public: @@ -2266,6 +2281,9 @@ public: AlterAlgorithm alter_algorithm_; bool alter_auto_partition_attr_; common::ObSArray rebuild_index_arg_list_; // pre split + uint32_t client_session_id_; + int64_t client_session_create_ts_; + transaction::tablelock::ObTableLockPriority lock_priority_; int serialize_index_args(char *buf, const int64_t data_len, int64_t &pos) const; int deserialize_index_args(const char *buf, const int64_t data_len, int64_t &pos); int64_t get_index_args_serialize_size() const; diff --git a/src/storage/tablelock/ob_table_lock_common.h b/src/storage/tablelock/ob_table_lock_common.h index 930e99277..e9c5aaf20 100644 --- a/src/storage/tablelock/ob_table_lock_common.h +++ b/src/storage/tablelock/ob_table_lock_common.h @@ -32,6 +32,14 @@ namespace transaction { namespace tablelock { +enum class ObTableLockPriority : int8_t +{ + INVALID = -1, + HIGH1 = 0, + HIGH2 = 10, + NORMAL = 20, + LOW = 30, +}; // Lock compatibility matrix: // diff --git a/src/storage/tablelock/ob_table_lock_rpc_struct.cpp b/src/storage/tablelock/ob_table_lock_rpc_struct.cpp index 8de73ea5e..938dfe306 100644 --- a/src/storage/tablelock/ob_table_lock_rpc_struct.cpp +++ b/src/storage/tablelock/ob_table_lock_rpc_struct.cpp @@ -31,7 +31,8 @@ OB_SERIALIZE_MEMBER(ObLockParam, is_try_lock_, expired_time_, schema_version_, - is_for_replace_); + is_for_replace_, + lock_priority_); OB_SERIALIZE_MEMBER(ObLockRequest, type_, @@ -39,7 +40,8 @@ OB_SERIALIZE_MEMBER(ObLockRequest, lock_mode_, op_type_, timeout_us_, - is_from_sql_); + is_from_sql_, + lock_priority_); OB_SERIALIZE_MEMBER_INHERIT(ObLockObjRequest, ObLockRequest, obj_type_, @@ -51,7 +53,9 @@ OB_SERIALIZE_MEMBER_INHERIT(ObLockObjsRequest, ObLockRequest, detect_param_); OB_SERIALIZE_MEMBER_INHERIT(ObLockTableRequest, ObLockRequest, - table_id_); + table_id_, + detect_func_no_, + detect_param_); OB_SERIALIZE_MEMBER_INHERIT(ObLockPartitionRequest, ObLockTableRequest, part_object_id_); @@ -199,6 +203,8 @@ void ObLockParam::reset() is_try_lock_ = true; expired_time_ = 0; schema_version_ = -1; + is_for_replace_ = false; + lock_priority_ = ObTableLockPriority::NORMAL; } int ObLockParam::set( @@ -257,6 +263,7 @@ void ObLockRequest::reset() op_type_ = UNKNOWN_TYPE; timeout_us_ = 0; is_from_sql_ = false; + lock_priority_ = ObTableLockPriority::NORMAL; } bool ObLockRequest::is_valid() const @@ -354,6 +361,8 @@ void ObLockTableRequest::reset() { ObLockRequest::reset(); table_id_ = 0; + detect_func_no_ = INVALID_DETECT_TYPE; + detect_param_.reset(); } bool ObLockTableRequest::is_valid() const diff --git a/src/storage/tablelock/ob_table_lock_rpc_struct.h b/src/storage/tablelock/ob_table_lock_rpc_struct.h index e4adc250c..fced8142d 100644 --- a/src/storage/tablelock/ob_table_lock_rpc_struct.h +++ b/src/storage/tablelock/ob_table_lock_rpc_struct.h @@ -74,7 +74,8 @@ public: is_try_lock_(true), expired_time_(0), schema_version_(-1), - is_for_replace_(false) + is_for_replace_(false), + lock_priority_(ObTableLockPriority::NORMAL) {} virtual ~ObLockParam() { reset(); } void reset(); @@ -106,6 +107,7 @@ public: // current schema version int64_t schema_version_; bool is_for_replace_; + ObTableLockPriority lock_priority_; }; struct ObLockRequest @@ -134,7 +136,8 @@ public: lock_mode_(NO_LOCK), op_type_(UNKNOWN_TYPE), timeout_us_(0), - is_from_sql_(false) + is_from_sql_(false), + lock_priority_(ObTableLockPriority::NORMAL) // default priority should be normal { type_ = ObLockMsgType::UNKNOWN_MSG_TYPE; } virtual ~ObLockRequest() { reset(); } virtual void reset(); @@ -161,6 +164,7 @@ public: ObTableLockOpType op_type_; int64_t timeout_us_; bool is_from_sql_; + ObTableLockPriority lock_priority_; }; struct ObLockObjRequest : public ObLockRequest @@ -223,7 +227,11 @@ struct ObLockTableRequest : public ObLockRequest { OB_UNIS_VERSION_V(1); public: - ObLockTableRequest() : ObLockRequest(), table_id_(0) + ObLockTableRequest() + : ObLockRequest(), + table_id_(0), + detect_func_no_(INVALID_DETECT_TYPE), + detect_param_() { type_ = ObLockMsgType::LOCK_TABLE_REQ; } virtual ~ObLockTableRequest() { reset(); } virtual void reset(); @@ -232,6 +240,8 @@ public: public: // which table should we lock uint64_t table_id_; + ObTableLockDetectType detect_func_no_; + ObString detect_param_; }; struct ObUnLockTableRequest : public ObLockTableRequest