提交 4640a92c 编写于 作者: S sl0 提交者: wangzelin.wzl

Bugfixs patched from 3.1.x to 3.1_opensource_release

上级 9bbbb315
...@@ -93,7 +93,7 @@ int ObAsyncPlanDriver::response_result(ObMySQLResultSet& result) ...@@ -93,7 +93,7 @@ int ObAsyncPlanDriver::response_result(ObMySQLResultSet& result)
if (!OB_SUCC(ret) && !async_resp_used && !retry_ctrl_.need_retry()) { if (!OB_SUCC(ret) && !async_resp_used && !retry_ctrl_.need_retry()) {
int sret = OB_SUCCESS; int sret = OB_SUCCESS;
bool is_partition_hit = session_.partition_hit().get_bool(); bool is_partition_hit = session_.get_err_final_partition_hit(ret);
if (OB_SUCCESS != (sret = sender_.send_error_packet(ret, NULL, is_partition_hit))) { if (OB_SUCCESS != (sret = sender_.send_error_packet(ret, NULL, is_partition_hit))) {
LOG_WARN("send error packet fail", K(sret), K(ret)); LOG_WARN("send error packet fail", K(sret), K(ret));
} }
......
...@@ -191,7 +191,7 @@ int ObSyncPlanDriver::response_result(ObMySQLResultSet& result) ...@@ -191,7 +191,7 @@ int ObSyncPlanDriver::response_result(ObMySQLResultSet& result)
OB_BATCHED_MULTI_STMT_ROLLBACK != ret) { OB_BATCHED_MULTI_STMT_ROLLBACK != ret) {
// if OB_BATCHED_MULTI_STMT_ROLLBACK is err ret of batch stmt rollback,not return to client, retry // if OB_BATCHED_MULTI_STMT_ROLLBACK is err ret of batch stmt rollback,not return to client, retry
int sret = OB_SUCCESS; int sret = OB_SUCCESS;
bool is_partition_hit = session_.partition_hit().get_bool(); bool is_partition_hit = session_.get_err_final_partition_hit(ret);
if (OB_SUCCESS != (sret = sender_.send_error_packet(ret, NULL, is_partition_hit))) { if (OB_SUCCESS != (sret = sender_.send_error_packet(ret, NULL, is_partition_hit))) {
LOG_WARN("send error packet fail", K(sret), K(ret)); LOG_WARN("send error packet fail", K(sret), K(ret));
} }
...@@ -433,7 +433,7 @@ int ObRemotePlanDriver::response_result(ObMySQLResultSet& result) ...@@ -433,7 +433,7 @@ int ObRemotePlanDriver::response_result(ObMySQLResultSet& result)
if (!retry_ctrl_.need_retry()) { if (!retry_ctrl_.need_retry()) {
if (OB_FAIL(ret) && !process_ok) { if (OB_FAIL(ret) && !process_ok) {
int sret = OB_SUCCESS; int sret = OB_SUCCESS;
bool is_partition_hit = session_.partition_hit().get_bool(); bool is_partition_hit = session_.get_err_final_partition_hit(ret);
if (OB_SUCCESS != (sret = sender_.send_error_packet(ret, NULL, is_partition_hit))) { if (OB_SUCCESS != (sret = sender_.send_error_packet(ret, NULL, is_partition_hit))) {
LOG_WARN("send error packet fail", K(sret), K(ret)); LOG_WARN("send error packet fail", K(sret), K(ret));
} }
......
...@@ -739,9 +739,13 @@ OB_INLINE int ObMPQuery::do_process( ...@@ -739,9 +739,13 @@ OB_INLINE int ObMPQuery::do_process(
} else { } else {
LOG_WARN("query failed", K(ret), K(retry_ctrl_.need_retry())); LOG_WARN("query failed", K(ret), K(retry_ctrl_.need_retry()));
} }
bool is_partition_hit = session.partition_hit().get_bool(); // 当need_retry=false时,可能给客户端回过包了,可能还没有回过任何包。
int err = send_error_packet(ret, NULL, is_partition_hit, (void*)&ctx_.reroute_info_); // 不过,可以确定:这个请求出错了,还没处理完。如果不是已经交给异步EndTrans收尾,
if (OB_SUCCESS != err) { // 则需要在下面回复一个error_packet作为收尾。否则后面没人帮忙发错误包给客户端了,
// 可能会导致客户端挂起等回包。
bool is_partition_hit = session.get_err_final_partition_hit(ret);
int err = send_error_packet(ret, NULL, is_partition_hit, (void *)&ctx_.reroute_info_);
if (OB_SUCCESS != err) { // 发送error包
LOG_WARN("send error packet failed", K(ret), K(err)); LOG_WARN("send error packet failed", K(ret), K(err));
} }
} }
......
...@@ -716,9 +716,13 @@ int ObMPStmtExecute::do_process( ...@@ -716,9 +716,13 @@ int ObMPStmtExecute::do_process(
&& !THIS_WORKER.need_retry() && !THIS_WORKER.need_retry()
&& !retry_ctrl_.need_retry()) { && !retry_ctrl_.need_retry()) {
LOG_WARN("query failed", K(ret), K(retry_ctrl_.need_retry()), K_(stmt_id)); LOG_WARN("query failed", K(ret), K(retry_ctrl_.need_retry()), K_(stmt_id));
bool is_partition_hit = session.partition_hit().get_bool(); // 当need_retry=false时,可能给客户端回过包了,可能还没有回过任何包。
int err = send_error_packet(ret, NULL, is_partition_hit, (void*)(&ctx_.reroute_info_)); // 不过,可以确定:这个请求出错了,还没处理完。如果不是已经交给异步EndTrans收尾,
if (OB_SUCCESS != err) { // 则需要在下面回复一个error_packet作为收尾。否则后面没人帮忙发错误包给客户端了,
// 可能会导致客户端挂起等回包。
bool is_partition_hit = session.get_err_final_partition_hit(ret);
int err = send_error_packet(ret, NULL, is_partition_hit, (void *)(&ctx_.reroute_info_));
if (OB_SUCCESS != err) { // 发送error包
LOG_WARN("send error packet failed", K(ret), K(err)); LOG_WARN("send error packet failed", K(ret), K(err));
} }
} }
......
...@@ -445,7 +445,11 @@ int ObMPStmtPrepare::do_process( ...@@ -445,7 +445,11 @@ int ObMPStmtPrepare::do_process(
if (!OB_SUCC(ret) && !async_resp_used && need_response_error && conn_valid_ && !THIS_WORKER.need_retry()) { if (!OB_SUCC(ret) && !async_resp_used && need_response_error && conn_valid_ && !THIS_WORKER.need_retry()) {
LOG_WARN("query failed", K(ret), K(retry_ctrl_.need_retry()), K_(sql)); LOG_WARN("query failed", K(ret), K(retry_ctrl_.need_retry()), K_(sql));
bool is_partition_hit = session.partition_hit().get_bool(); // 当need_retry=false时,可能给客户端回过包了,可能还没有回过任何包。
// 不过,可以确定:这个请求出错了,还没处理完。如果不是已经交给异步EndTrans收尾,
// 则需要在下面回复一个error_packet作为收尾。否则后面没人帮忙发错误包给客户端了,
// 可能会导致客户端挂起等回包。
bool is_partition_hit = session.get_err_final_partition_hit(ret);
int err = send_error_packet(ret, NULL, is_partition_hit); int err = send_error_packet(ret, NULL, is_partition_hit);
if (OB_SUCCESS != err) { if (OB_SUCCESS != err) {
LOG_WARN("send error packet failed", K(ret), K(err)); LOG_WARN("send error packet failed", K(ret), K(err));
......
...@@ -370,10 +370,15 @@ inline int ObExprTrim::deduce_result_type( ...@@ -370,10 +370,15 @@ inline int ObExprTrim::deduce_result_type(
if (lib::is_oracle_mode() && type_ctx.get_session()->use_static_typing_engine()) { if (lib::is_oracle_mode() && type_ctx.get_session()->use_static_typing_engine()) {
auto str_params = make_const_carray(str_type); auto str_params = make_const_carray(str_type);
LOG_DEBUG("str_type is", K(str_type)); LOG_DEBUG("str_type is", K(str_type));
OZ(aggregate_string_type_and_charset_oracle(*type_ctx.get_session(), str_params, type, true)); // prefer varchar if (str_type->is_null()) {
OZ(deduce_string_param_calc_type_and_charset(*type_ctx.get_session(), type, str_params)); type.set_meta(*str_type);
if (NULL != pattern_type) { } else {
pattern_type->set_calc_meta(type); OZ(aggregate_string_type_and_charset_oracle(*type_ctx.get_session(), str_params,
type, true)); // prefer varchar
OZ(deduce_string_param_calc_type_and_charset(*type_ctx.get_session(), type, str_params));
if (OB_SUCC(ret) && NULL != pattern_type) {
pattern_type->set_calc_meta(type);
}
} }
} else { } else {
if (str_type->is_lob()) { if (str_type->is_lob()) {
...@@ -389,6 +394,8 @@ inline int ObExprTrim::deduce_result_type( ...@@ -389,6 +394,8 @@ inline int ObExprTrim::deduce_result_type(
if (NULL != pattern_type) { if (NULL != pattern_type) {
pattern_type->set_calc_type(ObVarcharType); pattern_type->set_calc_type(ObVarcharType);
} }
} else if (str_type->is_null()) {
type.set_meta(*str_type);
} else { } else {
const common::ObLengthSemantics default_length_semantics = const common::ObLengthSemantics default_length_semantics =
(OB_NOT_NULL(type_ctx.get_session()) ? type_ctx.get_session()->get_actual_nls_length_semantics() (OB_NOT_NULL(type_ctx.get_session()) ? type_ctx.get_session()->get_actual_nls_length_semantics()
......
...@@ -51,33 +51,41 @@ int ObBasicNestedLoopJoin::prepare_rescan_params(ObBasicNestedLoopJoinCtx& join_ ...@@ -51,33 +51,41 @@ int ObBasicNestedLoopJoin::prepare_rescan_params(ObBasicNestedLoopJoinCtx& join_
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObObjParam res_obj; ObObjParam res_obj;
ObPhysicalPlanCtx* plan_ctx = join_ctx.exec_ctx_.get_physical_plan_ctx(); ObPhysicalPlanCtx *plan_ctx = join_ctx.exec_ctx_.get_physical_plan_ctx();
if (OB_ISNULL(plan_ctx) || OB_ISNULL(join_ctx.left_row_)) { ObPhyOperator *left_child = get_child(FIRST_CHILD);
ObPhyOperatorCtx *left_child_ctx = NULL;
if (OB_ISNULL(plan_ctx) || OB_ISNULL(join_ctx.left_row_) ||
OB_ISNULL(left_child)) {
ret = OB_BAD_NULL_ERROR; ret = OB_BAD_NULL_ERROR;
LOG_WARN("plan ctx or left row is null", K(ret)); LOG_WARN("plan ctx or left row is null", K(ret));
} else if (NULL ==
(left_child_ctx = static_cast<ObPhyOperatorCtx *>(
join_ctx.exec_ctx_.get_phy_op_ctx(left_child->get_id())))) {
LOG_WARN("fail to get phy operator ctx", K(ret));
} else { } else {
int64_t param_cnt = rescan_params_.count(); int64_t param_cnt = rescan_params_.count();
const ObSqlExpression* expr = NULL; const ObSqlExpression *expr = NULL;
// rescan param need deep copy, because memory of expr result from calc_buf
// in ObPhyOperator, when get next row next time, will free memory in
// calc_buf; here we use left child calc_buf, because when left child need
// get next row, rescan param will not used;
for (int64_t i = 0; OB_SUCC(ret) && i < param_cnt; ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < param_cnt; ++i) {
int64_t idx = rescan_params_.at(i).param_idx_;
if (OB_ISNULL(expr = rescan_params_.at(i).expr_)) { if (OB_ISNULL(expr = rescan_params_.at(i).expr_)) {
ret = OB_BAD_NULL_ERROR; ret = OB_BAD_NULL_ERROR;
LOG_WARN("rescan param expr is null", K(ret), K(i)); LOG_WARN("rescan param expr is null", K(ret), K(i));
} else if (OB_FAIL(expr->calc(join_ctx.expr_ctx_, *join_ctx.left_row_, res_obj))) { } else if (OB_FAIL(expr->calc(join_ctx.expr_ctx_, *join_ctx.left_row_, res_obj))) {
LOG_WARN("failed to calc expr for rescan param", K(ret), K(i)); LOG_WARN("failed to calc expr for rescan param", K(ret), K(i));
} else { } else {
int64_t idx = rescan_params_.at(i).param_idx_;
res_obj.set_param_meta(); res_obj.set_param_meta();
plan_ctx->get_param_store_for_update().at(idx) = res_obj; if (OB_FAIL(deep_copy_obj(
LOG_DEBUG("prepare_rescan_params", left_child_ctx->get_calc_buf(), res_obj,
K(ret), plan_ctx->get_param_store_for_update().at(idx)))) {
K(i), LOG_WARN("fail to deep copy ", K(ret));
K(res_obj), }
K(idx), LOG_DEBUG("prepare_rescan_params", K(ret), K(i), K(res_obj), K(idx),
K(expr), K(expr), K(plan_ctx), K(*join_ctx.left_row_), K(*expr),
K(plan_ctx), K(join_ctx.expr_ctx_.phy_plan_ctx_));
K(*join_ctx.left_row_),
K(*expr),
K(join_ctx.expr_ctx_.phy_plan_ctx_));
} }
} }
} }
......
...@@ -122,23 +122,35 @@ int ObNestedLoopJoin::switch_iterator(ObExecContext& ctx) const ...@@ -122,23 +122,35 @@ int ObNestedLoopJoin::switch_iterator(ObExecContext& ctx) const
return ret; return ret;
} }
int ObNestedLoopJoin::rescan(ObExecContext& exec_ctx) const int ObNestedLoopJoin::reset_rescan_params(ObExecContext &ctx) const {
{
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObNestedLoopJoinCtx* join_ctx = GET_PHY_OPERATOR_CTX(ObNestedLoopJoinCtx, exec_ctx, get_id()); ObPhysicalPlanCtx *plan_ctx = NULL;
ObPhysicalPlanCtx* plan_ctx = exec_ctx.get_physical_plan_ctx(); if (OB_ISNULL(plan_ctx = GET_PHY_PLAN_CTX(ctx))) {
if (OB_ISNULL(join_ctx) || OB_ISNULL(plan_ctx)) { ret = OB_ERR_UNEXPECTED;
ret = OB_BAD_NULL_ERROR; LOG_WARN("physical plan context is null", K(ret));
LOG_WARN("join ctx is null", K(ret));
} else { } else {
join_ctx->reset(); for (int64_t i = 0; i < rescan_params_.count(); ++i) {
int64_t param_cnt = rescan_params_.count();
for (int64_t i = 0; OB_SUCC(ret) && i < param_cnt; ++i) {
int64_t idx = rescan_params_.at(i).param_idx_; int64_t idx = rescan_params_.at(i).param_idx_;
plan_ctx->get_param_store_for_update().at(idx).set_null(); plan_ctx->get_param_store_for_update().at(idx).set_null();
LOG_DEBUG("prepare_rescan_params", K(ret), K(i), K(idx)); LOG_TRACE("prepare_rescan_params", K(ret), K(i), K(idx));
} }
if (OB_FAIL(ObBasicNestedLoopJoin::rescan(exec_ctx))) { }
return ret;
}
int ObNestedLoopJoin::rescan(ObExecContext &exec_ctx) const {
int ret = OB_SUCCESS;
ObNestedLoopJoinCtx *join_ctx =
GET_PHY_OPERATOR_CTX(ObNestedLoopJoinCtx, exec_ctx, get_id());
if (OB_ISNULL(join_ctx)) {
ret = OB_BAD_NULL_ERROR;
LOG_WARN("join ctx is null", K(ret));
} else {
join_ctx->reset();
if (OB_FAIL(reset_rescan_params(exec_ctx))) {
LOG_WARN("fail to reset rescan params", K(ret));
} else if (OB_FAIL(ObBasicNestedLoopJoin::rescan(exec_ctx))) {
LOG_WARN("failed to rescan", K(ret)); LOG_WARN("failed to rescan", K(ret));
} }
} }
...@@ -204,9 +216,16 @@ int ObNestedLoopJoin::inner_get_next_row(ObExecContext& exec_ctx, const ObNewRow ...@@ -204,9 +216,16 @@ int ObNestedLoopJoin::inner_get_next_row(ObExecContext& exec_ctx, const ObNewRow
LOG_WARN("copy current row failed", K(ret)); LOG_WARN("copy current row failed", K(ret));
} }
} }
if (OB_ITER_END == ret) {
if (OB_FAIL(reset_rescan_params(exec_ctx))) {
LOG_WARN("fail to reset rescan params", K(ret));
} else {
ret = OB_ITER_END;
}
}
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
LOG_DEBUG("get next row from nested loop join", K(*row)); LOG_TRACE("get next row from nested loop join", K(*row));
} }
return ret; return ret;
} }
......
...@@ -124,7 +124,9 @@ private: ...@@ -124,7 +124,9 @@ private:
state_operation_func_type state_operation_func_[JS_STATE_COUNT]; state_operation_func_type state_operation_func_[JS_STATE_COUNT];
state_function_func_type state_function_func_[JS_STATE_COUNT][FT_TYPE_COUNT]; state_function_func_type state_function_func_[JS_STATE_COUNT][FT_TYPE_COUNT];
// nested loop join with index seek, batch // nested loop join with index seek, batch
int batch_index_join_get_next(ObExecContext& exec_ctx, const common::ObNewRow*& row) const; int batch_index_join_get_next(ObExecContext &exec_ctx,
const common::ObNewRow *&row) const;
int reset_rescan_params(ObExecContext &ctx) const;
private: private:
int bij_fill_left_rows(ObExecContext& exec_ctx) const; int bij_fill_left_rows(ObExecContext& exec_ctx) const;
......
...@@ -73,12 +73,25 @@ int ObNestedLoopJoinOp::switch_iterator() ...@@ -73,12 +73,25 @@ int ObNestedLoopJoinOp::switch_iterator()
return ret; return ret;
} }
int ObNestedLoopJoinOp::rescan() int ObNestedLoopJoinOp::set_param_null() {
{ int ret = OB_SUCCESS;
ObDatum null_datum;
null_datum.set_null();
for (int64_t i = 0; OB_SUCC(ret) && i < MY_SPEC.rescan_params_.count(); ++i) {
OZ(MY_SPEC.rescan_params_.at(i).update_dynamic_param(eval_ctx_,
null_datum));
LOG_DEBUG("prepare_rescan_params", K(ret), K(i));
}
return ret;
}
int ObNestedLoopJoinOp::rescan() {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
reset_buf_state(); reset_buf_state();
ObPhysicalPlanCtx* plan_ctx = GET_PHY_PLAN_CTX(ctx_); ObPhysicalPlanCtx *plan_ctx = GET_PHY_PLAN_CTX(ctx_);
if (OB_FAIL(ObBasicNestedLoopJoinOp::rescan())) { if (OB_FAIL(set_param_null())) {
LOG_WARN("failed to set param null", K(ret));
} else if (OB_FAIL(ObBasicNestedLoopJoinOp::rescan())) {
LOG_WARN("failed to rescan", K(ret)); LOG_WARN("failed to rescan", K(ret));
} }
...@@ -117,6 +130,13 @@ int ObNestedLoopJoinOp::inner_get_next_row() ...@@ -117,6 +130,13 @@ int ObNestedLoopJoinOp::inner_get_next_row()
} }
} // while end } // while end
} }
if (OB_ITER_END == ret) {
if (OB_FAIL(set_param_null())) {
LOG_WARN("failed to set param null", K(ret));
} else {
ret = OB_ITER_END;
}
}
return ret; return ret;
} }
......
...@@ -93,6 +93,7 @@ private: ...@@ -93,6 +93,7 @@ private:
bool is_full() const; bool is_full() const;
// used for rescan and switch iter // used for rescan and switch iter
virtual void reset_buf_state(); virtual void reset_buf_state();
int set_param_null();
public: public:
ObJoinState state_; ObJoinState state_;
......
...@@ -204,25 +204,34 @@ void ObSubPlanFilter::reuse() ...@@ -204,25 +204,34 @@ void ObSubPlanFilter::reuse()
ObMultiChildrenPhyOperator::reuse(); ObMultiChildrenPhyOperator::reuse();
} }
int ObSubPlanFilter::rescan(ObExecContext& ctx) const int ObSubPlanFilter::reset_rescan_params(ObExecContext &ctx) const {
{
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObPhyOperator* child_op = NULL; ObPhysicalPlanCtx *plan_ctx = NULL;
ObSubPlanFilterCtx* subplan_ctx = NULL; if (OB_ISNULL(plan_ctx = GET_PHY_PLAN_CTX(ctx))) {
ObPhysicalPlanCtx* plan_ctx = NULL;
if (OB_ISNULL(subplan_ctx = GET_PHY_OPERATOR_CTX(ObSubPlanFilterCtx, ctx, get_id())) ||
OB_ISNULL(plan_ctx = ctx.get_physical_plan_ctx())) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("get physical operator context failed", K(ret)); LOG_WARN("physical plan context is null", K(ret));
} else { /*do nothing*/ } else {
for (int64_t i = 0; i < rescan_params_.count(); ++i) {
int64_t idx = rescan_params_.at(i).second;
plan_ctx->get_param_store_for_update().at(idx).set_null();
LOG_TRACE("prepare_rescan_params", K(ret), K(i), K(idx));
}
} }
for (int64_t i = 0; OB_SUCC(ret) && i < rescan_params_.count(); ++i) { return ret;
int64_t idx = rescan_params_.at(i).second; }
plan_ctx->get_param_store_for_update().at(idx).set_null();
LOG_DEBUG("prepare_rescan_params", K(ret), K(i), K(idx));
}
int ObSubPlanFilter::rescan(ObExecContext &ctx) const {
int ret = OB_SUCCESS;
ObPhyOperator *child_op = NULL;
ObSubPlanFilterCtx *subplan_ctx = NULL;
if (OB_ISNULL(subplan_ctx =
GET_PHY_OPERATOR_CTX(ObSubPlanFilterCtx, ctx, get_id()))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get physical operator context failed", K(ret));
} else if (OB_FAIL(reset_rescan_params(ctx))) {
LOG_WARN("fail to reset rescan params", K(ret));
}
for (int32_t i = 1; OB_SUCC(ret) && i < get_child_num(); ++i) { for (int32_t i = 1; OB_SUCC(ret) && i < get_child_num(); ++i) {
if (OB_ISNULL(child_op = get_child(i))) { if (OB_ISNULL(child_op = get_child(i))) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
...@@ -620,6 +629,13 @@ int ObSubPlanFilter::inner_get_next_row(ObExecContext& ctx, const ObNewRow*& row ...@@ -620,6 +629,13 @@ int ObSubPlanFilter::inner_get_next_row(ObExecContext& ctx, const ObNewRow*& row
OZ(copy_cur_row(*subplan_ctx, row)); OZ(copy_cur_row(*subplan_ctx, row));
} }
} }
if (OB_ITER_END == ret) {
if (OB_FAIL(reset_rescan_params(ctx))) {
LOG_WARN("fail to reset rescan params", K(ret));
} else {
ret = OB_ITER_END;
}
}
return ret; return ret;
} }
......
...@@ -104,6 +104,7 @@ private: ...@@ -104,6 +104,7 @@ private:
virtual int64_t to_string_kv(char* buf, const int64_t buf_len) const; virtual int64_t to_string_kv(char* buf, const int64_t buf_len) const;
int handle_update_set(ObSubPlanFilterCtx* subplan_ctx, const common::ObNewRow*& row) const; int handle_update_set(ObSubPlanFilterCtx* subplan_ctx, const common::ObNewRow*& row) const;
int construct_array_params(ObExecContext& ctx) const; int construct_array_params(ObExecContext& ctx) const;
int reset_rescan_params(ObExecContext &ctx) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(ObSubPlanFilter); DISALLOW_COPY_AND_ASSIGN(ObSubPlanFilter);
......
...@@ -325,6 +325,13 @@ int ObSubPlanFilterOp::inner_get_next_row() ...@@ -325,6 +325,13 @@ int ObSubPlanFilterOp::inner_get_next_row()
OZ(handle_update_set()); OZ(handle_update_set());
} }
} }
if (OB_ITER_END == ret) {
if (OB_FAIL(set_param_null())) {
LOG_WARN("failed to set param null", K(ret));
} else {
ret = OB_ITER_END;
}
}
return ret; return ret;
} }
......
...@@ -470,7 +470,7 @@ struct ObPlanCacheCtx { ...@@ -470,7 +470,7 @@ struct ObPlanCacheCtx {
must_be_positive_index_(), must_be_positive_index_(),
multi_stmt_fp_results_(allocator), multi_stmt_fp_results_(allocator),
handle_id_(MAX_HANDLE), handle_id_(MAX_HANDLE),
is_remote_executor_(false) is_remote_executor_(false)
{ {
bl_key_.tenant_id_ = tenant_id; bl_key_.tenant_id_ = tenant_id;
fp_result_.pc_key_.is_ps_mode_ = is_ps_mode_; fp_result_.pc_key_.is_ps_mode_ = is_ps_mode_;
......
...@@ -264,6 +264,7 @@ ObPsStmtInfo::ObPsStmtInfo(ObIAllocator* inner_allocator) ...@@ -264,6 +264,7 @@ ObPsStmtInfo::ObPsStmtInfo(ObIAllocator* inner_allocator)
dep_objs_(NULL), dep_objs_(NULL),
dep_objs_cnt_(0), dep_objs_cnt_(0),
ps_item_(NULL), ps_item_(NULL),
is_expired_evicted_(false),
allocator_(inner_allocator), allocator_(inner_allocator),
external_allocator_(NULL) external_allocator_(NULL)
...@@ -286,6 +287,7 @@ ObPsStmtInfo::ObPsStmtInfo(ObIAllocator* inner_allocator, ObIAllocator* external ...@@ -286,6 +287,7 @@ ObPsStmtInfo::ObPsStmtInfo(ObIAllocator* inner_allocator, ObIAllocator* external
ps_item_(NULL), ps_item_(NULL),
tenant_version_(OB_INVALID_VERSION), tenant_version_(OB_INVALID_VERSION),
is_expired_(false), is_expired_(false),
is_expired_evicted_(false),
allocator_(inner_allocator), allocator_(inner_allocator),
external_allocator_(external_allocator) external_allocator_(external_allocator)
{} {}
...@@ -312,6 +314,7 @@ int ObPsStmtInfo::deep_copy(const ObPsStmtInfo& other) ...@@ -312,6 +314,7 @@ int ObPsStmtInfo::deep_copy(const ObPsStmtInfo& other)
ps_item_ = other.ps_item_; ps_item_ = other.ps_item_;
tenant_version_ = other.tenant_version_; tenant_version_ = other.tenant_version_;
is_expired_ = other.is_expired_; is_expired_ = other.is_expired_;
is_expired_evicted_ = other.is_expired_evicted_;
if (other.get_dep_objs_cnt() > 0) { if (other.get_dep_objs_cnt() > 0) {
dep_objs_cnt_ = other.get_dep_objs_cnt(); dep_objs_cnt_ = other.get_dep_objs_cnt();
if (NULL == (dep_objs_ = reinterpret_cast<ObSchemaObjVersion*>( if (NULL == (dep_objs_ = reinterpret_cast<ObSchemaObjVersion*>(
......
...@@ -321,14 +321,9 @@ public: ...@@ -321,14 +321,9 @@ public:
{ {
tenant_version_ = tenant_version; tenant_version_ = tenant_version;
} }
void set_is_expired() void set_is_expired() { ATOMIC_STORE(&is_expired_, true); }
{ bool is_expired() { return ATOMIC_LOAD(&is_expired_); }
ATOMIC_STORE(&is_expired_, true); bool *get_is_expired_evicted_ptr() { return &is_expired_evicted_; }
}
int64_t is_expired()
{
return ATOMIC_LOAD(&is_expired_);
}
DECLARE_VIRTUAL_TO_STRING; DECLARE_VIRTUAL_TO_STRING;
...@@ -351,6 +346,8 @@ private: ...@@ -351,6 +346,8 @@ private:
ObPsStmtItem* ps_item_; ObPsStmtItem* ps_item_;
int64_t tenant_version_; int64_t tenant_version_;
bool is_expired_; bool is_expired_;
// check whether has dec ref count for ps info expired
bool is_expired_evicted_;
// ObDataBuffer is used to use the internal memory of ObPsStmtItem, // ObDataBuffer is used to use the internal memory of ObPsStmtItem,
// The memory essentially comes from inner_allocator_ in ObPsPlancache // The memory essentially comes from inner_allocator_ in ObPsPlancache
......
...@@ -46,19 +46,10 @@ ObPsCache::ObPsCache() ...@@ -46,19 +46,10 @@ ObPsCache::ObPsCache()
ObPsCache::~ObPsCache() ObPsCache::~ObPsCache()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObSEArray<ObPsStmtId, 512> all_stmt_id; // ps_stmt_id和ps_stmt_info创建时,会给其增加引用计数
ObGetAllStmtIdOp op(&all_stmt_id); // 现在PsCache要析构了,对所有内部对象减去1,如果引用计数到0,会显式free内存
if (OB_FAIL(stmt_info_map_.foreach_refactored(op))) { cache_evict_all_ps();
LOG_WARN("traverse stmt_info_map_ failed", K(ret));
} else if (OB_FAIL(op.get_callback_ret())) {
LOG_WARN("traverse stmt_info_map_ failed", K(ret));
} else {
for (int64_t i = 0; i < all_stmt_id.count(); ++i) { // ignore ret
if (OB_FAIL(deref_ps_stmt(all_stmt_id.at(i), true /*erase_info*/))) {
LOG_WARN("deref_ps_stmt faield when destroy ObPsCache", K(ret), K(all_stmt_id.at(i)), K(all_stmt_id.count()));
}
}
}
if (NULL != mem_context_) { if (NULL != mem_context_) {
DESTROY_CONTEXT(mem_context_); DESTROY_CONTEXT(mem_context_);
mem_context_ = NULL; mem_context_ = NULL;
......
...@@ -43,8 +43,14 @@ public: ...@@ -43,8 +43,14 @@ public:
id_time.first = entry.first; id_time.first = entry.first;
id_time.second = entry.second->get_last_closed_timestamp(); id_time.second = entry.second->get_last_closed_timestamp();
if (entry.second->is_expired()) { if (entry.second->is_expired()) {
if (OB_SUCCESS != (callback_ret_ = expired_ps_->push_back(id_time))) { // for expired ps info, only evicted once;
SQL_PC_LOG(WARN, "fail to push back key", K_(callback_ret)); // use cas, because auto cache evict and flush ps cache may concurrent
// processing
if (ATOMIC_BCAS(entry.second->get_is_expired_evicted_ptr(), false,
true)) {
if (OB_SUCCESS != (callback_ret_ = expired_ps_->push_back(id_time))) {
SQL_PC_LOG(WARN, "fail to push back key", K_(callback_ret));
}
} }
} else { } else {
if (OB_SUCCESS != (callback_ret_ = closed_ps_->push_back(id_time))) { if (OB_SUCCESS != (callback_ret_ = closed_ps_->push_back(id_time))) {
......
...@@ -295,6 +295,7 @@ int ObColumnNamespaceChecker::find_column_in_single_table( ...@@ -295,6 +295,7 @@ int ObColumnNamespaceChecker::find_column_in_single_table(
// if databasename or table name is not specified, // if databasename or table name is not specified,
// we must check the uniqueness of column in the table with the same name // we must check the uniqueness of column in the table with the same name
bool is_match = true; bool is_match = true;
LOG_TRACE("column info", K(q_name), K(table_item));
if (!q_name.database_name_.empty()) { if (!q_name.database_name_.empty()) {
if (OB_FAIL(ObResolverUtils::name_case_cmp( if (OB_FAIL(ObResolverUtils::name_case_cmp(
params_.session_info_, q_name.database_name_, table_item.database_name_, OB_TABLE_NAME_CLASS, is_match))) { params_.session_info_, q_name.database_name_, table_item.database_name_, OB_TABLE_NAME_CLASS, is_match))) {
...@@ -314,11 +315,6 @@ int ObColumnNamespaceChecker::find_column_in_single_table( ...@@ -314,11 +315,6 @@ int ObColumnNamespaceChecker::find_column_in_single_table(
params_.session_info_, q_name.tbl_name_, table_item.get_object_name(), OB_TABLE_NAME_CLASS, is_match))) { params_.session_info_, q_name.tbl_name_, table_item.get_object_name(), OB_TABLE_NAME_CLASS, is_match))) {
LOG_WARN("database name case compare failed", K(ret)); LOG_WARN("database name case compare failed", K(ret));
} }
if (OB_SUCC(ret) && !is_match && !table_item.synonym_name_.empty() &&
OB_FAIL(ObResolverUtils::name_case_cmp(
params_.session_info_, q_name.tbl_name_, table_item.synonym_name_, OB_TABLE_NAME_CLASS, is_match))) {
LOG_WARN("database name case compare failed", K(ret));
}
} }
if (OB_SUCC(ret) && is_match) { if (OB_SUCC(ret) && is_match) {
if (OB_FAIL(check_column_exists(table_item, q_name.col_name_, is_match))) { if (OB_FAIL(check_column_exists(table_item, q_name.col_name_, is_match))) {
......
...@@ -567,6 +567,7 @@ int ObDMLResolver::resolve_basic_column_item(const TableItem& table_item, const ...@@ -567,6 +567,7 @@ int ObDMLResolver::resolve_basic_column_item(const TableItem& table_item, const
col_expr->set_synonym_db_name(table_item.synonym_db_name_); col_expr->set_synonym_db_name(table_item.synonym_db_name_);
col_expr->set_synonym_name(table_item.synonym_name_); col_expr->set_synonym_name(table_item.synonym_name_);
col_expr->set_column_attr(table_item.get_table_name(), col_schema->get_column_name_str()); col_expr->set_column_attr(table_item.get_table_name(), col_schema->get_column_name_str());
col_expr->set_from_alias_table(!table_item.alias_name_.empty());
col_expr->set_database_name(table_item.database_name_); col_expr->set_database_name(table_item.database_name_);
// column maybe from alias table, so must reset ref id by table id from table_item // column maybe from alias table, so must reset ref id by table id from table_item
col_expr->set_ref_id(table_item.table_id_, col_schema->get_column_id()); col_expr->set_ref_id(table_item.table_id_, col_schema->get_column_id());
......
...@@ -1989,6 +1989,7 @@ public: ...@@ -1989,6 +1989,7 @@ public:
is_lob_column_(false), is_lob_column_(false),
is_unpivot_mocked_column_(false), is_unpivot_mocked_column_(false),
is_hidden_(false), is_hidden_(false),
from_alias_table_(false),
real_expr_(nullptr) real_expr_(nullptr)
{ {
set_expr_class(ObExpr::EXPR_COLUMN_REF); set_expr_class(ObExpr::EXPR_COLUMN_REF);
...@@ -2010,6 +2011,7 @@ public: ...@@ -2010,6 +2011,7 @@ public:
is_lob_column_(false), is_lob_column_(false),
is_unpivot_mocked_column_(false), is_unpivot_mocked_column_(false),
is_hidden_(false), is_hidden_(false),
from_alias_table_(false),
real_expr_(nullptr) real_expr_(nullptr)
{ {
set_expr_class(ObExpr::EXPR_COLUMN_REF); set_expr_class(ObExpr::EXPR_COLUMN_REF);
...@@ -2031,6 +2033,7 @@ public: ...@@ -2031,6 +2033,7 @@ public:
is_lob_column_(false), is_lob_column_(false),
is_unpivot_mocked_column_(false), is_unpivot_mocked_column_(false),
is_hidden_(false), is_hidden_(false),
from_alias_table_(false),
real_expr_(nullptr) real_expr_(nullptr)
{ {
set_expr_class(ObExpr::EXPR_COLUMN_REF); set_expr_class(ObExpr::EXPR_COLUMN_REF);
...@@ -2119,6 +2122,9 @@ public: ...@@ -2119,6 +2122,9 @@ public:
virtual int do_visit(ObRawExprVisitor& visitor) override; virtual int do_visit(ObRawExprVisitor& visitor) override;
virtual uint64_t hash_internal(uint64_t seed) const; virtual uint64_t hash_internal(uint64_t seed) const;
bool is_from_alias_table() const { return from_alias_table_; }
void set_from_alias_table(bool value) { from_alias_table_ = value; }
inline bool is_generated_column() const inline bool is_generated_column() const
{ {
return share::schema::ObSchemaUtils::is_generated_column(column_flags_); return share::schema::ObSchemaUtils::is_generated_column(column_flags_);
...@@ -2226,6 +2232,7 @@ private: ...@@ -2226,6 +2232,7 @@ private:
bool is_lob_column_; // TODO add lob column bool is_lob_column_; // TODO add lob column
bool is_unpivot_mocked_column_; // used for unpivot bool is_unpivot_mocked_column_; // used for unpivot
bool is_hidden_; // used for print hidden column bool is_hidden_; // used for print hidden column
bool from_alias_table_;
ObRawExpr* real_expr_; // for oracle virtual table that is mapping a real table ObRawExpr* real_expr_; // for oracle virtual table that is mapping a real table
}; };
......
...@@ -280,6 +280,9 @@ int ObRawExprPrinter::print(ObColumnRefRawExpr* expr) ...@@ -280,6 +280,9 @@ int ObRawExprPrinter::print(ObColumnRefRawExpr* expr)
is_oracle_mode ? "\"%.*s\".\"%.*s\"" : "`%.*s`.`%.*s`", LEN_AND_PTR(table_name), LEN_AND_PTR(col_name)); is_oracle_mode ? "\"%.*s\".\"%.*s\"" : "`%.*s`.`%.*s`", LEN_AND_PTR(table_name), LEN_AND_PTR(col_name));
} else if (OB_UNLIKELY(only_column_namespace_)) { } else if (OB_UNLIKELY(only_column_namespace_)) {
DATA_PRINTF(is_oracle_mode ? "\"%.*s\"" : "`%.*s`", LEN_AND_PTR(col_name)); DATA_PRINTF(is_oracle_mode ? "\"%.*s\"" : "`%.*s`", LEN_AND_PTR(col_name));
} else if (expr->is_from_alias_table()) {
DATA_PRINTF(is_oracle_mode ? "\"%.*s\".\"%.*s\"" : "`%.*s`.`%.*s`",
LEN_AND_PTR(expr->get_table_name()), LEN_AND_PTR(col_name));
} else { } else {
if (!expr->get_synonym_name().empty() && !expr->get_synonym_db_name().empty()) { if (!expr->get_synonym_name().empty() && !expr->get_synonym_db_name().empty()) {
ObString synonyn_db_name = expr->get_synonym_db_name(); ObString synonyn_db_name = expr->get_synonym_db_name();
......
...@@ -1259,48 +1259,31 @@ public: ...@@ -1259,48 +1259,31 @@ public:
int get_max_allowed_packet(int64_t& max_allowed_pkt) const; int get_max_allowed_packet(int64_t& max_allowed_pkt) const;
int get_net_buffer_length(int64_t& net_buffer_len) const; int get_net_buffer_length(int64_t& net_buffer_len) const;
/// @} /// @}
int64_t get_session_info_mem_size() const int64_t get_session_info_mem_size() const { return block_allocator_.get_total_mem_size(); }
{ int64_t get_sys_var_mem_size() const { return base_sys_var_alloc_.total(); }
return block_allocator_.get_total_mem_size(); ObPartitionHitInfo &partition_hit() { return partition_hit_; } // 和上面的set_partition_hit没有任何关系
} bool get_err_final_partition_hit(int err_ret)
int64_t get_sys_var_mem_size() const {
{ bool is_partition_hit = partition_hit().get_bool();
return base_sys_var_alloc_.total(); if (is_proxy_refresh_location_ret(err_ret)) {
} is_partition_hit = false;
// for improving cache miss of proxy, nothing to do with the set_partition_hit() above. } else if (get_is_in_retry()
ObPartitionHitInfo& partition_hit() && is_proxy_refresh_location_ret(retry_info_.get_last_query_retry_err())) {
{ is_partition_hit = false;
return partition_hit_; }
} return is_partition_hit;
void set_shadow(bool is_shadow) };
{ bool is_proxy_refresh_location_ret(int err_ret) {
ATOMIC_STORE(&thread_data_.is_shadow_, is_shadow); return common::OB_NOT_MASTER == err_ret;
} }
bool is_shadow() void set_shadow(bool is_shadow) { ATOMIC_STORE(&thread_data_.is_shadow_, is_shadow); }
{ bool is_shadow() { return ATOMIC_LOAD(&thread_data_.is_shadow_); }
return ATOMIC_LOAD(&thread_data_.is_shadow_); uint32_t get_version() const {return version_;}
} uint32_t get_magic_num() {return magic_num_;}
uint32_t get_version() const int64_t get_current_execution_id() const { return current_execution_id_; }
{ const common::ObCurTraceId::TraceId &get_last_trace_id() const { return last_trace_id_; }
return version_; void set_current_execution_id(int64_t execution_id) { current_execution_id_ = execution_id; }
} void set_last_trace_id(common::ObCurTraceId::TraceId *trace_id)
uint32_t get_magic_num()
{
return magic_num_;
}
int64_t get_current_execution_id() const
{
return current_execution_id_;
}
const common::ObCurTraceId::TraceId& get_last_trace_id() const
{
return last_trace_id_;
}
void set_current_execution_id(int64_t execution_id)
{
current_execution_id_ = execution_id;
}
void set_last_trace_id(common::ObCurTraceId::TraceId* trace_id)
{ {
if (OB_ISNULL(trace_id)) { if (OB_ISNULL(trace_id)) {
} else { } else {
......
...@@ -803,7 +803,9 @@ int ObSQLSessionInfo::get_ps_session_info(const ObPsStmtId stmt_id, ObPsSessionI ...@@ -803,7 +803,9 @@ int ObSQLSessionInfo::get_ps_session_info(const ObPsStmtId stmt_id, ObPsSessionI
int ObSQLSessionInfo::remove_ps_session_info(const ObPsStmtId stmt_id) int ObSQLSessionInfo::remove_ps_session_info(const ObPsStmtId stmt_id)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObPsSessionInfo* session_info = NULL; ObPsSessionInfo *session_info = NULL;
LOG_TRACE("remove ps session info", K(ret), K(stmt_id), K(get_sessid()),
K(lbt()));
if (OB_FAIL(ps_session_info_map_.erase_refactored(stmt_id, &session_info))) { if (OB_FAIL(ps_session_info_map_.erase_refactored(stmt_id, &session_info))) {
LOG_WARN("ps session info not exist", K(stmt_id)); LOG_WARN("ps session info not exist", K(stmt_id));
} else if (OB_ISNULL(session_info)) { } else if (OB_ISNULL(session_info)) {
......
...@@ -65110,8 +65110,8 @@ SQL: select * from vv1; ...@@ -65110,8 +65110,8 @@ SQL: select * from vv1;
] ]
}, },
"is_alias":false, "is_alias":false,
"alias_name":"(`opt`.`t1`.`c1` + 2)", "alias_name":"(`t1`.`c1` + 2)",
"expr_name":"(`opt`.`t1`.`c1` + 2)", "expr_name":"(`t1`.`c1` + 2)",
"default": { "default": {
"NULL":"NULL" "NULL":"NULL"
}, },
...@@ -65355,7 +65355,7 @@ SQL: select * from vv1; ...@@ -65355,7 +65355,7 @@ SQL: select * from vv1;
}, },
"is_alias":false, "is_alias":false,
"alias_name":"c1", "alias_name":"c1",
"expr_name":"`opt`.`t1`.`c1`", "expr_name":"`t1`.`c1`",
"default": { "default": {
"NULL":"NULL" "NULL":"NULL"
}, },
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册