fix spm bugs when modify inner table
This commit is contained in:
@ -555,6 +555,7 @@ void ObPhysicalPlan::update_plan_stat(const ObAuditRecordData &record,
|
||||
// - (record.exec_timestamp_.run_ts_ - record.exec_timestamp_.receive_ts_));
|
||||
ATOMIC_AAF(&(stat_.evolution_stat_.cpu_time_), record.exec_timestamp_.executor_t_);
|
||||
ATOMIC_AAF(&(stat_.evolution_stat_.elapsed_time_), record.get_elapsed_time());
|
||||
ATOMIC_STORE(&(stat_.evolution_stat_.last_exec_ts_), record.exec_timestamp_.executor_end_ts_);
|
||||
}
|
||||
if (stat_.is_bind_sensitive_ && execute_count > 0) {
|
||||
int64_t pos = execute_count % ObPlanStat::MAX_SCAN_STAT_SIZE;
|
||||
|
||||
@ -210,11 +210,6 @@ int64_t ObILibCacheNode::dec_ref_count(const CacheRefHandleID ref_handle)
|
||||
LOG_ERROR("invalid null lib cache");
|
||||
} else {
|
||||
ObLCNodeFactory &ln_factory = lib_cache_->get_cache_node_factory();
|
||||
if (OB_FAIL(before_cache_evicted())) {
|
||||
LOG_WARN("failed to process before_cache_evicted", K(ret));
|
||||
}
|
||||
// regardless of whether before_cache_evicted succeeds or fails, the cache node
|
||||
// will be evicted. so ignore the error code here
|
||||
lib_cache_->dec_mem_used(get_mem_size());
|
||||
ln_factory.destroy_cache_node(this);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public:
|
||||
ObPlanBaselineMgr* baseline_mgr_;
|
||||
};
|
||||
|
||||
typedef ObList<EvolutionTaskResult*, ObIAllocator> task_result_list;
|
||||
typedef ObList<EvoResultUpdateTask*, ObIAllocator> task_result_list;
|
||||
|
||||
class ObPlanBaselineMgr
|
||||
{
|
||||
@ -90,7 +90,6 @@ public:
|
||||
int force_accept_new_plan_baseline(ObSpmCacheCtx& spm_ctx, uint64_t plan_hash, const bool with_plan_hash);
|
||||
int sync_baseline_from_inner_table();
|
||||
int sync_baseline_from_server();
|
||||
int sync_baseline_before_evict(ObBaselineKey &key, ObIArray<ObPlanBaselineItem*>& baselines);
|
||||
|
||||
int alter_plan_baseline(const uint64_t tenant_id,
|
||||
const uint64_t database_id,
|
||||
|
||||
@ -113,6 +113,26 @@ public:
|
||||
const ObString &input_str,
|
||||
ObString &output_str);
|
||||
|
||||
int update_plan_baselines_result(const uint64_t tenant_id,
|
||||
EvoResultUpdateTask& evo_res);
|
||||
|
||||
int update_baseline_item_evolving_result(ObMySQLTransaction& trans,
|
||||
const uint64_t tenant_id,
|
||||
const ObBaselineKey& key,
|
||||
const uint64_t& plan_hash,
|
||||
const ObEvolutionStat &evo_stat,
|
||||
int64_t& affected_rows);
|
||||
|
||||
int insert_new_baseline(ObIAllocator& allocator,
|
||||
const uint64_t tenant_id,
|
||||
const ObBaselineKey& key,
|
||||
ObPlanBaselineItem* baseline);
|
||||
|
||||
int insert_new_baseline_item(ObMySQLTransaction& trans,
|
||||
ObIAllocator& allocator,
|
||||
const uint64_t tenant_id,
|
||||
const ObBaselineKey& key,
|
||||
const ObPlanBaselineItem& baseline_item);
|
||||
private:
|
||||
const static char *EMPTY_STR;
|
||||
bool inited_;
|
||||
|
||||
@ -222,7 +222,6 @@ public:
|
||||
virtual int inner_add_cache_obj(ObILibCacheCtx &ctx,
|
||||
ObILibCacheKey *key,
|
||||
ObILibCacheObject *cache_obj) override;
|
||||
virtual int before_cache_evicted() override;
|
||||
void destroy();
|
||||
void set_baseline_key(ObBaselineKey &key) { baseline_key_ = key; }
|
||||
ObBaselineKey &get_baseline_key() { return baseline_key_; }
|
||||
@ -364,6 +363,23 @@ public:
|
||||
ObEvolutionStat new_stat_;
|
||||
};
|
||||
|
||||
struct EvoResultUpdateTask
|
||||
{
|
||||
public:
|
||||
EvoResultUpdateTask()
|
||||
: key_(),
|
||||
plan_hash_(),
|
||||
plan_stat_()
|
||||
{}
|
||||
~EvoResultUpdateTask() {}
|
||||
int init_task(common::ObIAllocator& allocator, const EvolutionTaskResult& evo_task_result);
|
||||
TO_STRING_KV(K_(key), K_(plan_hash), K_(plan_stat));
|
||||
public:
|
||||
ObBaselineKey key_;
|
||||
common::ObSEArray<uint64_t, 4> plan_hash_;
|
||||
common::ObSEArray<ObEvolutionStat, 4> plan_stat_;
|
||||
};
|
||||
|
||||
} // namespace sql end
|
||||
} // namespace oceanbase end
|
||||
|
||||
|
||||
@ -26,13 +26,15 @@ public:
|
||||
: executions_(0),
|
||||
cpu_time_(0),
|
||||
elapsed_time_(0),
|
||||
error_cnt_(0)
|
||||
error_cnt_(0),
|
||||
last_exec_ts_(0)
|
||||
{}
|
||||
ObEvolutionStat(const ObEvolutionStat &other)
|
||||
: executions_(other.executions_),
|
||||
cpu_time_(other.cpu_time_),
|
||||
elapsed_time_(other.elapsed_time_),
|
||||
error_cnt_(other.error_cnt_)
|
||||
error_cnt_(other.error_cnt_),
|
||||
last_exec_ts_(other.last_exec_ts_)
|
||||
{}
|
||||
virtual ~ObEvolutionStat() {}
|
||||
inline void reset()
|
||||
@ -41,6 +43,7 @@ public:
|
||||
cpu_time_ = 0;
|
||||
elapsed_time_ = 0;
|
||||
error_cnt_ = 0;
|
||||
last_exec_ts_ = 0;
|
||||
}
|
||||
inline ObEvolutionStat& operator=(const ObEvolutionStat &other)
|
||||
{
|
||||
@ -49,15 +52,17 @@ public:
|
||||
cpu_time_ = other.cpu_time_;
|
||||
elapsed_time_ = other.elapsed_time_;
|
||||
error_cnt_ = other.error_cnt_;
|
||||
last_exec_ts_ = other.last_exec_ts_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
TO_STRING_KV(K_(executions), K_(cpu_time), K_(elapsed_time), K_(error_cnt));
|
||||
TO_STRING_KV(K_(executions), K_(cpu_time), K_(elapsed_time), K_(error_cnt), K_(last_exec_ts));
|
||||
public:
|
||||
int64_t executions_; // The total number of executions in the evolution process
|
||||
int64_t cpu_time_; // The total CPU time consumed during the evolution process
|
||||
int64_t elapsed_time_;
|
||||
int64_t error_cnt_;
|
||||
int64_t last_exec_ts_;
|
||||
};
|
||||
|
||||
struct AlterPlanBaselineArg
|
||||
|
||||
Reference in New Issue
Block a user