fix set feedback info bug

This commit is contained in:
zzg19950727
2024-07-05 08:46:54 +00:00
committed by ob-robot
parent 7757b9e743
commit 7a69d9c304
4 changed files with 14 additions and 3 deletions

View File

@ -142,7 +142,8 @@ ObPhysicalPlan::ObPhysicalPlan(MemoryContext &mem_context /* = CURRENT_CONTEXT *
enable_inc_direct_load_(false),
enable_replace_(false),
insert_overwrite_(false),
online_sample_percent_(1.)
online_sample_percent_(1.),
can_set_feedback_info_(true)
{
}
@ -244,6 +245,7 @@ void ObPhysicalPlan::reset()
enable_replace_ = false;
insert_overwrite_ = false;
online_sample_percent_ = 1.;
can_set_feedback_info_.store(true);
}
void ObPhysicalPlan::destroy()
{
@ -1409,5 +1411,12 @@ int ObPhysicalPlan::set_all_local_session_vars(ObIArray<ObLocalSessionVar> *all_
return ret;
}
bool ObPhysicalPlan::try_record_plan_info()
{
bool expected = true;
bool b_ret = can_set_feedback_info_.compare_exchange_strong(expected, false);
return b_ret;
}
} //namespace sql
} //namespace oceanbase

View File

@ -356,6 +356,7 @@ public:
inline uint64_t get_append_table_id() const { return append_table_id_; }
void set_record_plan_info(bool v) { need_record_plan_info_ = v; }
bool need_record_plan_info() const { return need_record_plan_info_; }
bool try_record_plan_info();
const common::ObString &get_rule_name() const { return stat_.rule_name_; }
inline void set_is_rewrite_sql(bool v) { stat_.is_rewrite_sql_ = v; }
inline bool is_rewrite_sql() const { return stat_.is_rewrite_sql_; }
@ -708,6 +709,7 @@ private:
bool enable_replace_; // for incremental direct load
bool insert_overwrite_; // for insert overwrite
double online_sample_percent_; // for incremental direct load
std::atomic<bool> can_set_feedback_info_;
};
inline void ObPhysicalPlan::set_affected_last_insert_id(bool affected_last_insert_id)

View File

@ -708,7 +708,7 @@ int ObRemoteBaseExecuteP<T>::execute_with_sql(ObRemoteTask &task)
NG_TRACE_EXT(execute_task, OB_ID(task), task, OB_ID(stmt_type), plan->get_stmt_type());
if (OB_FAIL(execute_remote_plan(exec_ctx_, *plan))) {
LOG_WARN("execute remote plan failed", K(ret), K(task), K(exec_ctx_.get_das_ctx().get_snapshot()));
} else if (plan->need_record_plan_info()) {
} else if (plan->try_record_plan_info()) {
if(exec_ctx_.get_feedback_info().is_valid() &&
plan->get_logical_plan().is_valid() &&
OB_FAIL(plan->set_feedback_info(exec_ctx_))) {

View File

@ -890,7 +890,7 @@ OB_INLINE int ObResultSet::do_close_plan(int errcode, ObExecContext &ctx)
ret = sret;
}
if (OB_SUCC(ret)) {
if (physical_plan_->need_record_plan_info()) {
if (physical_plan_->try_record_plan_info()) {
if (ctx.get_feedback_info().is_valid() &&
physical_plan_->get_logical_plan().is_valid() &&
OB_FAIL(physical_plan_->set_feedback_info(ctx))) {