[DeadLock.bad_case] fix remote sql retry may deadlock
This commit is contained in:
@ -124,7 +124,8 @@ ObExecContext::ObExecContext(ObIAllocator &allocator)
|
||||
is_ps_prepare_stage_(false),
|
||||
register_op_id_(OB_INVALID_ID),
|
||||
tmp_alloc_used_(false),
|
||||
table_direct_insert_ctx_()
|
||||
table_direct_insert_ctx_(),
|
||||
errcode_(OB_SUCCESS)
|
||||
{
|
||||
}
|
||||
|
||||
@ -181,6 +182,7 @@ ObExecContext::~ObExecContext()
|
||||
temp_expr_ctx_map_.destroy();
|
||||
}
|
||||
update_columns_ = nullptr;
|
||||
errcode_ = OB_SUCCESS;
|
||||
}
|
||||
|
||||
void ObExecContext::clean_resolve_ctx()
|
||||
|
||||
@ -459,6 +459,8 @@ public:
|
||||
eval_tmp_allocator_.set_attr(attr);
|
||||
}
|
||||
ObTableDirectInsertCtx &get_table_direct_insert_ctx() { return table_direct_insert_ctx_; }
|
||||
void set_errcode(const int errcode) { ATOMIC_STORE(&errcode_, errcode); }
|
||||
int get_errcode() const { return ATOMIC_LOAD(&errcode_); }
|
||||
private:
|
||||
int build_temp_expr_ctx(const ObTempExpr &temp_expr, ObTempExprCtx *&temp_expr_ctx);
|
||||
int set_phy_op_ctx_ptr(uint64_t index, void *phy_op);
|
||||
@ -631,6 +633,8 @@ protected:
|
||||
// -------------------
|
||||
// for direct insert
|
||||
ObTableDirectInsertCtx table_direct_insert_ctx_;
|
||||
// for deadlock detect, set in do_close_plan
|
||||
int errcode_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExecContext);
|
||||
};
|
||||
|
||||
@ -743,6 +743,7 @@ OB_INLINE int ObResultSet::do_close_plan(int errcode, ObExecContext &ctx)
|
||||
err_ignored = plan_ctx->is_error_ignored();
|
||||
}
|
||||
bool rollback = need_rollback(ret, errcode, err_ignored);
|
||||
get_exec_context().set_errcode(errcode);
|
||||
sret = end_stmt(rollback || OB_SUCCESS != pret);
|
||||
// SQL_LOG(INFO, "end_stmt err code", K_(errcode), K(ret), K(pret), K(sret));
|
||||
// if branch fail is returned from end_stmt, then return it first
|
||||
|
||||
@ -783,6 +783,7 @@ int ObSqlTransControl::end_stmt(ObExecContext &exec_ctx, const bool rollback)
|
||||
OZ (get_tx_service(session, txs), *session);
|
||||
// plain select stmt don't require txn descriptor
|
||||
if (OB_SUCC(ret) && !is_plain_select) {
|
||||
ObTransDeadlockDetectorAdapter::maintain_deadlock_info_when_end_stmt(exec_ctx, rollback);
|
||||
CK (OB_NOT_NULL(tx_desc));
|
||||
auto &tx_result = session->get_trans_result();
|
||||
if (OB_FAIL(ret)) {
|
||||
@ -817,10 +818,6 @@ int ObSqlTransControl::end_stmt(ObExecContext &exec_ctx, const bool rollback)
|
||||
ret = COVER_SUCC(tmp_ret);
|
||||
}
|
||||
|
||||
if (!is_plain_select) {
|
||||
ObTransDeadlockDetectorAdapter::maintain_deadlock_info_when_end_stmt(exec_ctx, rollback);
|
||||
}
|
||||
|
||||
bool print_log = false;
|
||||
#ifndef NDEBUG
|
||||
print_log = true;
|
||||
@ -835,7 +832,8 @@ int ObSqlTransControl::end_stmt(ObExecContext &exec_ctx, const bool rollback)
|
||||
"tx_desc", PC(session->get_tx_desc()),
|
||||
"trans_result", session->get_trans_result(),
|
||||
K(rollback),
|
||||
KPC(session));
|
||||
KPC(session),
|
||||
K(exec_ctx.get_errcode()));
|
||||
}
|
||||
if (OB_NOT_NULL(session)) {
|
||||
session->get_trans_result().reset();
|
||||
|
||||
Reference in New Issue
Block a user