提交 f27ecbb7 编写于 作者: O obdev 提交者: wangzelin.wzl

opensource bigfix patch

上级 2c4f8593
......@@ -570,7 +570,30 @@ int ObObj::deep_copy(const ObObj& src, char* buf, const int64_t size, int64_t& p
return ret;
}
bool ObObj::can_compare(const ObObj& other) const
void* ObObj::get_deep_copy_obj_ptr()
{
void * ptr = NULL;
if (ob_is_string_type(this->get_type())) {
// val_len_ == 0 is empty string, and it may point to unexpected address
// Therefore, reset it to NULL
if (val_len_ != 0) {
ptr = (void *)v_.string_;
}
} else if (ob_is_raw(this->get_type())) {
ptr = (void *)v_.string_;
} else if (ob_is_number_tc(this->get_type())) {
ptr = (void *)v_.nmb_digits_;
} else if (ob_is_rowid_tc(this->get_type())) {
ptr = (void *)v_.string_;
} else if (ob_is_lob_locator(this->get_type())) {
ptr = (void *)&v_.lob_locator_;
} else {
// do nothing
}
return ptr;
}
bool ObObj::can_compare(const ObObj &other) const
{
obj_cmp_func cmp_func = NULL;
return (is_min_value() || is_max_value() || other.is_min_value() || other.is_max_value() ||
......
......@@ -2084,10 +2084,11 @@ public:
//@{ deep copy
bool need_deep_copy() const;
OB_INLINE int64_t get_deep_copy_size() const;
int deep_copy(const ObObj& src, char* buf, const int64_t size, int64_t& pos);
void set_data_ptr(void* data_ptr);
const void* get_data_ptr() const;
// return byte length
int deep_copy(const ObObj &src, char *buf, const int64_t size, int64_t &pos);
void* get_deep_copy_obj_ptr();
void set_data_ptr(void *data_ptr);
const void *get_data_ptr() const;
//return byte length
int64_t get_data_length() const;
template <typename Allocator>
......
......@@ -818,6 +818,9 @@ const uint64_t OB_ORA_SYS_DATABASE_ID = 6;
const uint64_t OB_ORA_LBACSYS_DATABASE_ID = 7;
const uint64_t OB_ORA_AUDITOR_DATABASE_ID = 8;
const char* const OB_ORA_PUBLIC_SCHEMA_NAME = "PUBLIC";
// not actual database, only for using and creating outlines without specified database
const uint64_t OB_OUTLINE_DEFAULT_DATABASE_ID = 9;
const char* const OB_OUTLINE_DEFAULT_DATABASE_NAME = "__outline_default_db";
// sys unit associated const
const uint64_t OB_SYS_UNIT_CONFIG_ID = 1;
......
......@@ -71,7 +71,7 @@ public:
static const int32_t BATCH_RELEASE_COUNT = 50000;
static const int32_t MAX_RELEASE_TIME = 5 * 1000; // 5ms
static const int64_t US_PER_HOUR = 3600000000;
static const int64_t MAX_QUEUE_SIZE = 1000000; // 100w
static const int64_t MAX_QUEUE_SIZE = 10000000; // 10m
static const int64_t MINI_MODE_MAX_QUEUE_SIZE = 100000; // 10w
// start to eliminate when sql_audit more than 9 millions records
static const int64_t HIGH_LEVEL_EVICT_SIZE = 9000000; // 900w
......
......@@ -473,6 +473,10 @@ int ObInnerSQLConnection::process_retry(
if (need_retry) {
LOG_WARN("need retry, set ret to OB_SUCCESS", K(ret), K(last_ret), K(retry_cnt));
retry_info.set_last_query_retry_err(last_ret);
if (OB_ISNULL(extern_session_)) {
} else {
extern_session_->get_retry_info_for_update().set_last_query_retry_err(last_ret);
}
ret = OB_SUCCESS;
}
return ret;
......
......@@ -156,7 +156,10 @@ int ObTenantVirtualOutline::fill_cells(const ObOutlineInfo* outline_info)
}
case DATABASE_NAME: {
DBInfo db_info;
if (OB_FAIL(database_infos_.get_refactored(outline_info->get_database_id(), db_info))) {
if (outline_info->get_database_id()==OB_OUTLINE_DEFAULT_DATABASE_ID) {
cells[cell_idx].set_varchar(OB_OUTLINE_DEFAULT_DATABASE_NAME);
cells[cell_idx].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
} else if (OB_FAIL(database_infos_.get_refactored(outline_info->get_database_id(), db_info))) {
LOG_WARN("fail to ge value from database_infos", K(ret), K(outline_info->get_database_id()));
} else {
cells[cell_idx].set_varchar(db_info.db_name_);
......@@ -224,6 +227,10 @@ int ObTenantVirtualOutline::is_output_outline(const ObOutlineInfo* outline_info,
LOG_WARN("parameter is NULL", K(ret), K(outline_info), K(schema_guard_));
} else if (outline_info->get_outline_content_str().empty()) {
is_output = false;
} else if (outline_info->get_database_id() == OB_OUTLINE_DEFAULT_DATABASE_ID) {
// __outline_default_db is a logical table and has no physical schema.
// Therefore, always output this.
is_output = true;
} else if (OB_FAIL(is_database_recycle(outline_info->get_database_id(), is_recycle))) {
LOG_WARN("fail to judge database recycle", K(ret), KPC(outline_info));
} else {
......
......@@ -18807,13 +18807,15 @@ int ObDDLService::drop_outline(const obrpc::ObDropOutlineArg& arg)
uint64_t database_id = OB_INVALID_ID;
if (OB_SUCC(ret)) {
bool database_exist = false;
if (OB_FAIL(schema_service_->check_database_exist(tenant_id, database_name, database_id, database_exist))) {
LOG_WARN("failed to check database exist!",
K(tenant_id),
K(database_name),
K(database_id),
K(database_exist),
K(ret));
if (database_name == OB_OUTLINE_DEFAULT_DATABASE_NAME) {
database_id = OB_OUTLINE_DEFAULT_DATABASE_ID;
database_exist = true;
} else if (OB_FAIL(schema_service_->check_database_exist(tenant_id,
database_name,
database_id,
database_exist))) {
LOG_WARN("failed to check database exist!", K(tenant_id), K(database_name),
K(database_id), K(database_exist), K(ret));
} else if (!database_exist) {
ret = OB_ERR_BAD_DATABASE;
LOG_USER_ERROR(OB_ERR_BAD_DATABASE, database_name.length(), database_name.ptr());
......@@ -6357,6 +6357,9 @@ int ObRootService::create_outline(const ObCreateOutlineArg& arg)
const ObDatabaseSchema* db_schema = NULL;
if (OB_FAIL(ddl_service_.get_tenant_schema_guard_with_version_in_inner_table(tenant_id, schema_guard))) {
LOG_WARN("get schema guard in inner table failed", K(ret));
} else if (database_name == OB_OUTLINE_DEFAULT_DATABASE_NAME) {
// if not specify database, set default database name and database id;
outline_info.set_database_id(OB_OUTLINE_DEFAULT_DATABASE_ID);
} else if (OB_FAIL(schema_guard.get_database_schema(tenant_id, database_name, db_schema))) {
LOG_WARN("get database schema failed", K(ret));
} else if (NULL == db_schema) {
......
......@@ -90,18 +90,8 @@ public:
virtual void destroy();
virtual void reset();
void set_is_last_open_succ(bool val)
{
stat_.is_last_open_succ_ = val;
}
bool is_last_open_succ() const
{
return stat_.is_last_open_succ_;
}
bool from_plan_baseline() const
{
return common::OB_INVALID_ID != stat_.bl_info_.plan_baseline_id_;
}
void set_is_last_exec_succ(bool val) { stat_.is_last_exec_succ_ = val; }
bool is_last_exec_succ() const { return stat_.is_last_exec_succ_; }
const ObString& get_constructed_sql() const
{
return stat_.bl_info_.key_.constructed_sql_;
......
......@@ -128,12 +128,6 @@ OB_INLINE int ObResultSet::open_plan()
}
}
}
if (OB_FAIL(ret)) {
physical_plan_->set_is_last_open_succ(false);
} else {
physical_plan_->set_is_last_open_succ(true);
}
}
return ret;
}
......@@ -143,6 +137,19 @@ int ObResultSet::sync_open()
int ret = OB_SUCCESS;
OZ(execute());
OZ(open());
if (OB_NOT_NULL(cmd_)) {
// cmd not set
} else if (ret == OB_NOT_INIT) {
// phy plan not init, do nothing
} else if (OB_ISNULL(physical_plan_)) {
LOG_WARN("empty physical plan");
} else if (OB_FAIL(ret)) {
physical_plan_->set_is_last_exec_succ(false);
} else {
physical_plan_->set_is_last_exec_succ(true);
}
return ret;
}
......@@ -478,12 +485,15 @@ OB_INLINE int ObResultSet::end_participant(const bool is_rollback)
int ObResultSet::get_next_row(const common::ObNewRow*& row)
{
int& ret = errcode_;
if (OB_LIKELY(NULL != physical_plan_)) { // take this branch more frequently
// last_exec_succ default values is true
if (OB_LIKELY(NULL != physical_plan_)) { // take this branch more frequently
if (OB_ISNULL(exec_result_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("exec result is null", K(ret));
} else if (OB_FAIL(exec_result_->get_next_row(get_exec_context(), row))) {
if (OB_ITER_END != ret) {
// marked last execute status
physical_plan_->set_is_last_exec_succ(false);
LOG_WARN("get next row from exec result failed", K(ret));
}
} else {
......
......@@ -1154,13 +1154,20 @@ inline int ObSql::handle_text_query(const ObString& stmt, ObSqlCtx& context, ObR
} else {
context.cur_sql_ = trimed_stmt;
pc_ctx = new (pc_ctx) ObPlanCacheCtx(trimed_stmt,
false, /*is_ps_mode*/
allocator,
context,
ectx,
tenant_id);
if (OB_FAIL(session.get_database_id(pc_ctx->bl_key_.db_id_))) {
false, /*is_ps_mode*/
allocator,
context,
ectx,
tenant_id);
uint64_t database_id = OB_INVALID_ID;
if (OB_FAIL(session.get_database_id(database_id))) {
LOG_WARN("Failed to get database id", K(ret));
} else if (FALSE_IT(pc_ctx->bl_key_.db_id_ =
(database_id == OB_INVALID_ID) ?
OB_OUTLINE_DEFAULT_DATABASE_ID:
database_id)) {
// do nothing
} else if (!use_plan_cache) {
if (context.multi_stmt_item_.is_batched_multi_stmt()) {
ret = OB_BATCHED_MULTI_STMT_ROLLBACK;
......
......@@ -1606,8 +1606,13 @@ int ObPlanCache::construct_plan_cache_key(ObPlanCacheCtx& plan_ctx, ObjNameSpace
int ObPlanCache::construct_plan_cache_key(ObSQLSessionInfo& session, ObjNameSpace ns, ObPlanCacheKey& pc_key)
{
int ret = OB_SUCCESS;
if (OB_FAIL(session.get_database_id(pc_key.db_id_))) {
uint64_t database_id = OB_INVALID_ID;
if (OB_FAIL(session.get_database_id(database_id))) {
LOG_WARN("get database id failed", K(ret));
} else if (FALSE_IT(pc_key.db_id_ = (database_id == OB_INVALID_ID) ?
OB_OUTLINE_DEFAULT_DATABASE_ID
: database_id)) {
// do nothing
} else {
pc_key.namespace_ = ns;
pc_key.sys_vars_str_ = session.get_sys_var_in_pc_str();
......
......@@ -294,11 +294,11 @@ public:
int dump_all_objs() const;
template <DumpType dump_type>
int dump_deleted_objs(common::ObIArray<DeletedCacheObjInfo>& deleted_objs, const int64_t safe_timestamp) const;
static common::ObMemAttr get_mem_attr()
common::ObMemAttr get_mem_attr()
{
common::ObMemAttr attr;
attr.label_ = ObNewModIds::OB_SQL_PLAN_CACHE;
attr.tenant_id_ = OB_INVALID_ID;
attr.tenant_id_ = tenant_id_;
attr.ctx_id_ = ObCtxIds::PLAN_CACHE_CTX_ID;
return attr;
}
......
......@@ -698,7 +698,7 @@ struct ObPlanStat {
int64_t expected_worker_count_;
int64_t outline_version_;
int64_t outline_id_;
bool is_last_open_succ_;
bool is_last_exec_succ_;
common::ObString sp_info_str_;
common::ObString param_infos_;
common::ObString sys_vars_str_;
......@@ -782,7 +782,7 @@ struct ObPlanStat {
expected_worker_count_(-1),
outline_version_(common::OB_INVALID_VERSION),
outline_id_(common::OB_INVALID_ID),
is_last_open_succ_(true),
is_last_exec_succ_(true),
is_evolution_(false),
asyn_baseline_stat_(ASYN_NOTHING),
is_bind_sensitive_(false),
......@@ -847,7 +847,7 @@ struct ObPlanStat {
expected_worker_count_(rhs.expected_worker_count_),
outline_version_(rhs.outline_version_),
outline_id_(rhs.outline_id_),
is_last_open_succ_(rhs.is_last_open_succ_),
is_last_exec_succ_(rhs.is_last_exec_succ_),
is_evolution_(rhs.is_evolution_),
asyn_baseline_stat_(rhs.asyn_baseline_stat_),
bl_info_(rhs.bl_info_),
......@@ -996,7 +996,7 @@ struct ObPlanStat {
K_(execute_times), K_(disk_reads), K_(direct_writes), K_(buffer_gets), K_(application_wait_time),
K_(concurrency_wait_time), K_(user_io_wait_time), K_(rows_processed), K_(elapsed_time), K_(cpu_time),
K_(large_querys), K_(delayed_large_querys), K_(outline_version), K_(outline_id), K_(is_evolution),
K_(is_last_open_succ), K_(is_bind_sensitive), K_(is_bind_aware), K_(is_last_open_succ), K_(timeout_count),
K_(is_last_exec_succ), K_(is_bind_sensitive), K_(is_bind_aware), K_(is_last_exec_succ), K_(timeout_count),
K_(bl_info));
};
......
......@@ -151,10 +151,12 @@ ObPlanCacheValue::ObPlanCacheValue()
int ObPlanCacheValue::init(ObPCVSet* pcv_set, const ObCacheObject* cache_obj, ObPlanCacheCtx& pc_ctx)
{
int ret = OB_SUCCESS;
ObMemAttr mem_attr = ObPlanCache::get_mem_attr();
if (OB_ISNULL(pcv_set) || OB_ISNULL(cache_obj)) {
ObMemAttr mem_attr;
if (OB_ISNULL(pcv_set) || OB_ISNULL(cache_obj) || OB_ISNULL(pcv_set->get_plan_cache())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(pcv_set), K(cache_obj));
} else if (FALSE_IT(mem_attr = pcv_set->get_plan_cache()->get_mem_attr())) {
// do nothing
} else if (OB_ISNULL(pc_alloc_ = pcv_set->get_pc_allocator())) {
LOG_WARN("invalid argument", K(pcv_set->get_pc_allocator()));
} else if (OB_FAIL(outline_params_wrapper_.set_allocator(pc_alloc_, mem_attr))) {
......@@ -840,6 +842,20 @@ void ObPlanCacheValue::reset()
not_param_info_.at(i).raw_text_.reset();
}
}
for (int64_t i = 0; i < not_param_var_.count(); i++) {
// deep-copy destory
// free v
ObObjParam param = not_param_var_.at(i).ps_param_;
void * ptr = param.get_deep_copy_obj_ptr();
if (NULL == ptr){
// do nothing
} else {
pc_alloc_->free(ptr);
not_param_var_.at(i).ps_param_.reset();
}
}
if (NULL != outline_signature_.ptr()) {
pc_alloc_->free(outline_signature_.ptr());
outline_signature_.reset();
......@@ -851,6 +867,7 @@ void ObPlanCacheValue::reset()
}
not_param_info_.reset();
not_param_index_.reset();
not_param_var_.reset();
neg_param_index_.reset();
param_charset_type_.reset();
sql_traits_.reset();
......
......@@ -1195,8 +1195,9 @@ int ObSqlPlanSet::get_local_plan_direct(ObPlanCacheCtx& pc_ctx, bool& is_direct_
plan = local_plan_;
}
if (OB_SUCC(ret) && plan != NULL) {
int last_retry_err = pc_ctx.sql_ctx_.session_info_->get_retry_info().get_last_query_retry_err();
if (plan->is_last_open_succ()) {
int last_retry_err = pc_ctx.sql_ctx_.session_info_
->get_retry_info().get_last_query_retry_err();
if (plan->is_last_exec_succ()) {
is_direct_local_plan = true;
} else if (pc_ctx.sql_ctx_.session_info_->get_is_in_retry() && is_local_plan_opt_allowed(last_retry_err)) {
is_direct_local_plan = true;
......
......@@ -60,8 +60,7 @@ int ObOutlineResolver::resolve_outline_name(const ParseNode* node, ObString& db_
bool perserve_lettercase = share::is_oracle_mode() ? true : (mode != OB_LOWERCASE_AND_INSENSITIVE);
if (NULL == db_name_node) {
if (session_info_->get_database_name().empty()) {
ret = OB_ERR_NO_DB_SELECTED;
LOG_WARN("no database selected");
db_name = OB_OUTLINE_DEFAULT_DATABASE_NAME;
} else {
db_name = session_info_->get_database_name();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册