fix task aborted status is not persisted to the internal table bug

This commit is contained in:
obdev
2023-03-21 17:00:23 +00:00
committed by ob-robot
parent 1ec233bb5d
commit d760428489
14 changed files with 401 additions and 235 deletions

View File

@ -46,6 +46,23 @@ public:
int64_t schema_version_;
};
struct ObDDLTaskID final
{
public:
ObDDLTaskID();
ObDDLTaskID(const uint64_t tenant_id, const int64_t task_id);
~ObDDLTaskID() = default;
uint64_t hash() const;
bool operator==(const ObDDLTaskID &other) const;
bool operator!=(const ObDDLTaskID &other) const;
bool is_valid() const { return OB_INVALID_TENANT_ID != tenant_id_ && task_id_ > 0; }
int assign(const ObDDLTaskID &other);
TO_STRING_KV(K_(tenant_id), K_(task_id));
public:
uint64_t tenant_id_;
int64_t task_id_;
};
struct ObDDLTaskRecord final
{
public:
@ -87,6 +104,22 @@ public:
int64_t row_inserted_;
};
struct ObDDLTaskSerializeField final
{
OB_UNIS_VERSION(1);
public:
TO_STRING_KV(K_(task_version), K_(parallelism), K_(data_format_version), K_(is_abort));
ObDDLTaskSerializeField() : task_version_(0), parallelism_(0), data_format_version_(0), is_abort_(false) {}
ObDDLTaskSerializeField(const int64_t task_version, const int64_t parallelism,
const int64_t data_format_version, const bool is_abort);
~ObDDLTaskSerializeField() = default;
void reset();
public:
int64_t task_version_;
int64_t parallelism_;
int64_t data_format_version_;
bool is_abort_;
};
struct ObCreateDDLTaskParam final
{
public:
@ -384,7 +417,7 @@ class ObDDLTask : public common::ObDLinkBase<ObDDLTask>
{
public:
explicit ObDDLTask(const share::ObDDLType task_type)
: lock_(), ddl_tracing_(this), is_inited_(false), need_retry_(true), is_running_(false),
: lock_(), ddl_tracing_(this), is_inited_(false), need_retry_(true), is_running_(false), is_abort_(false),
task_type_(task_type), trace_id_(), tenant_id_(0), object_id_(0), schema_version_(0),
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),
@ -402,6 +435,8 @@ public:
share::ObDDLType get_task_type() const { return task_type_; }
void set_not_running() { ATOMIC_SET(&is_running_, false); }
void set_task_status(const share::ObDDLTaskStatus new_status) {task_status_ = new_status; }
void set_is_abort(const bool is_abort) { is_abort_ = is_abort; }
bool get_is_abort() { return is_abort_; }
bool try_set_running() { return !ATOMIC_CAS(&is_running_, false, true); }
uint64_t get_tenant_id() const { return tenant_id_; }
uint64_t get_object_id() const { return object_id_; }
@ -412,6 +447,7 @@ public:
int get_ddl_type_str(const int64_t ddl_type, const char *&ddl_type_str);
int64_t get_ret_code() const { return ret_code_; }
int64_t get_task_id() const { return task_id_; }
ObDDLTaskID get_ddl_task_id() const { return ObDDLTaskID(tenant_id_, task_id_); }
ObDDLTaskKey get_task_key() const { return ObDDLTaskKey(target_object_id_, schema_version_); }
int64_t get_parent_task_id() const { return parent_task_id_; }
int64_t get_task_version() const { return task_version_; }
@ -423,9 +459,9 @@ public:
share::ObDDLLongopsStat *get_longops_stat() const { return longops_stat_; }
int64_t get_data_format_version() const { return data_format_version_; }
static int fetch_new_task_id(ObMySQLProxy &sql_proxy, int64_t &new_task_id);
virtual int serialize_params_to_message(char *buf, const int64_t buf_size, int64_t &pos) const = 0;
virtual int deserlize_params_from_message(const uint64_t tenant_id, const char *buf, const int64_t buf_size, int64_t &pos) = 0;
virtual int64_t get_serialize_param_size() const = 0;
virtual int serialize_params_to_message(char *buf, const int64_t buf_size, int64_t &pos) const;
virtual int deserlize_params_from_message(const uint64_t tenant_id, const char *buf, const int64_t buf_size, int64_t &pos);
virtual int64_t get_serialize_param_size() const;
const ObString &get_ddl_stmt_str() const { return ddl_stmt_str_; }
int set_ddl_stmt_str(const ObString &ddl_stmt_str);
int convert_to_record(ObDDLTaskRecord &task_record, common::ObIAllocator &allocator);
@ -434,6 +470,7 @@ public:
int refresh_schema_version();
int remove_task_record();
int report_error_code(const ObString &forward_user_message, const int64_t affected_rows = 0);
int check_ddl_task_is_cancel(const TraceId &trace_id, bool &is_cancel);
int wait_trans_end(
ObDDLWaitTransEndCtx &wait_trans_ctx,
const share::ObDDLTaskStatus next_task_status);
@ -507,6 +544,7 @@ protected:
bool is_inited_;
bool need_retry_;
bool is_running_;
bool is_abort_;
share::ObDDLType task_type_;
TraceId trace_id_;
uint64_t tenant_id_;