[CP] [4_2_x] the statistics of rollback times is lost in ac = 1
This commit is contained in:
parent
95525551e8
commit
4367984c08
@ -74,6 +74,7 @@ int ObAsyncPlanDriver::response_result(ObMySQLResultSet &result)
|
||||
int cli_ret = OB_SUCCESS;
|
||||
retry_ctrl_.test_and_save_retry_state(gctx_, ctx_, result, ret, cli_ret);
|
||||
if (retry_ctrl_.need_retry()) {
|
||||
result.set_will_retry();
|
||||
result.set_end_trans_async(false);
|
||||
}
|
||||
// close背后的故事:
|
||||
|
@ -82,6 +82,9 @@ int ObSyncPlanDriver::response_result(ObMySQLResultSet &result)
|
||||
K(ret), K(cli_ret), K(retry_ctrl_.need_retry()));
|
||||
}
|
||||
}
|
||||
if (retry_ctrl_.need_retry()) {
|
||||
result.set_will_retry();
|
||||
}
|
||||
cret = result.close(cli_ret);
|
||||
if (cret != OB_SUCCESS &&
|
||||
cret != OB_TRANSACTION_SET_VIOLATION &&
|
||||
@ -115,6 +118,9 @@ int ObSyncPlanDriver::response_result(ObMySQLResultSet &result)
|
||||
} else {
|
||||
result.refresh_location_cache_by_errno(true, ret);
|
||||
}
|
||||
if (retry_ctrl_.need_retry()) {
|
||||
result.set_will_retry();
|
||||
}
|
||||
int cret = result.close(ret);
|
||||
if (cret != OB_SUCCESS) {
|
||||
LOG_WARN("close result set fail", K(cret));
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "sql/plan_cache/ob_cache_object_factory.h"
|
||||
#include "share/ob_cluster_version.h"
|
||||
#include "storage/tx/ob_trans_define.h"
|
||||
#include "storage/tx/ob_trans_event.h"
|
||||
#include "pl/ob_pl_user_type.h"
|
||||
#include "pl/ob_pl_stmt.h"
|
||||
#include "observer/ob_server_struct.h"
|
||||
@ -839,6 +840,7 @@ int ObResultSet::do_close(int *client_ret)
|
||||
LinkExecCtxGuard link_guard(my_session_, get_exec_context());
|
||||
|
||||
FLTSpanGuard(close);
|
||||
const bool is_tx_active = my_session_.is_in_transaction();
|
||||
int do_close_plan_ret = OB_SUCCESS;
|
||||
ObPhysicalPlan* physical_plan_ = static_cast<ObPhysicalPlan*>(cache_obj_guard_.get_cache_obj());
|
||||
if (OB_LIKELY(NULL != physical_plan_)) {
|
||||
@ -935,7 +937,7 @@ int ObResultSet::do_close(int *client_ret)
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = auto_end_plan_trans(*physical_plan_, ret, async);
|
||||
ret = auto_end_plan_trans(*physical_plan_, ret, is_tx_active, async);
|
||||
}
|
||||
|
||||
if (is_user_sql_ && my_session_.need_reset_package()) {
|
||||
@ -965,6 +967,7 @@ int ObResultSet::do_close(int *client_ret)
|
||||
// 2. TODO:对于commit/rollback这个cmd,后面也需要走这个路径。现在还是走同步Callback。
|
||||
OB_INLINE int ObResultSet::auto_end_plan_trans(ObPhysicalPlan& plan,
|
||||
int ret,
|
||||
bool is_tx_active,
|
||||
bool &async)
|
||||
{
|
||||
NG_TRACE(auto_end_plan_begin);
|
||||
@ -1005,6 +1008,11 @@ OB_INLINE int ObResultSet::auto_end_plan_trans(ObPhysicalPlan& plan,
|
||||
} else {
|
||||
//bool is_rollback = (OB_FAIL(ret) || plan_ctx->is_force_rollback());
|
||||
is_rollback = need_rollback(OB_SUCCESS, ret, plan_ctx->is_error_ignored());
|
||||
// if txn will be rollbacked and it may has been rollbacked in end-stmt phase
|
||||
// we need account this for stat
|
||||
if (is_rollback && !is_will_retry_() && is_tx_active && !in_trans) {
|
||||
ObTransStatistic::get_instance().add_rollback_trans_count(MTL_ID(), 1);
|
||||
}
|
||||
// 对于UPDATE等异步提交的语句,如果需要重试,那么中途的rollback也走同步接口
|
||||
if (OB_LIKELY(false == is_end_trans_async()) || OB_LIKELY(false == is_user_sql_)) {
|
||||
// 如果没有设置end_trans_cb,就走同步接口。这个主要是为了InnerSQL提供的。
|
||||
|
@ -332,6 +332,7 @@ public:
|
||||
const ObField &field,
|
||||
obmysql::ObMySQLField &mfield);
|
||||
void set_close_fail_callback(ObFunction<void(const int, int&)> func) { close_fail_cb_ = func; }
|
||||
void set_will_retry() { will_retry_ = true; }
|
||||
private:
|
||||
// types and constants
|
||||
static const int64_t TRANSACTION_SET_VIOLATION_MAX_RETRY = 3;
|
||||
@ -349,7 +350,7 @@ private:
|
||||
bool transaction_set_violation_and_retry(int &err, int64_t &retry);
|
||||
int init_cmd_exec_context(ObExecContext &exec_ctx);
|
||||
int on_cmd_execute();
|
||||
int auto_end_plan_trans(ObPhysicalPlan& plan, int ret, bool &async);
|
||||
int auto_end_plan_trans(ObPhysicalPlan& plan, int ret, bool is_tx_active, bool &async);
|
||||
int do_close(int *client_ret = NULL);
|
||||
void store_affected_rows(ObPhysicalPlanCtx &plan_ctx);
|
||||
void store_found_rows(ObPhysicalPlanCtx &plan_ctx);
|
||||
@ -373,7 +374,7 @@ private:
|
||||
oceanbase::observer::ObReqTimeInfo &req_timeinfo = observer::ObReqTimeInfo::get_thread_local_instance();
|
||||
req_timeinfo.update_end_time();
|
||||
}
|
||||
|
||||
bool is_will_retry_() const { return will_retry_; }
|
||||
protected:
|
||||
// 区分本ResultSet是为User还是Inner SQL服务, 服务于EndTrans异步回调
|
||||
bool is_user_sql_;
|
||||
@ -433,6 +434,7 @@ private:
|
||||
bool is_returning_;
|
||||
bool is_com_filed_list_; //used to mark COM_FIELD_LIST
|
||||
bool need_revert_tx_; //dblink
|
||||
bool will_retry_; // the query will retry, to figure out the final close
|
||||
common::ObString wild_str_;//uesd to save filed wildcard in COM_FIELD_LIST;
|
||||
common::ObString ps_sql_; // for sql in pl
|
||||
bool is_init_;
|
||||
@ -509,6 +511,7 @@ inline ObResultSet::ObResultSet(ObSQLSessionInfo &session, common::ObIAllocator
|
||||
is_returning_(false),
|
||||
is_com_filed_list_(false),
|
||||
need_revert_tx_(false),
|
||||
will_retry_(false),
|
||||
wild_str_(),
|
||||
ps_sql_(),
|
||||
is_init_(false),
|
||||
|
Loading…
x
Reference in New Issue
Block a user