提交 90a9d6d7 编写于 作者: W wgs13579 提交者: guangshu.wgs

optimize timeout of anonymous block

上级 93b2e020
...@@ -559,6 +559,7 @@ int ObSqlParseResult::load_result(const ObProxyParseResult &parse_result, ...@@ -559,6 +559,7 @@ int ObSqlParseResult::load_result(const ObProxyParseResult &parse_result,
has_shard_comment_ = parse_result.has_shard_comment_; has_shard_comment_ = parse_result.has_shard_comment_;
has_last_insert_id_ = parse_result.has_last_insert_id_; has_last_insert_id_ = parse_result.has_last_insert_id_;
hint_query_timeout_ = parse_result.query_timeout_; hint_query_timeout_ = parse_result.query_timeout_;
has_anonymous_block_ = parse_result.has_anonymous_block_;
stmt_type_ = parse_result.stmt_type_; stmt_type_ = parse_result.stmt_type_;
cmd_sub_type_ = parse_result.sub_stmt_type_; cmd_sub_type_ = parse_result.sub_stmt_type_;
hint_consistency_level_ = static_cast<ObConsistencyLevel>(parse_result.read_consistency_type_); hint_consistency_level_ = static_cast<ObConsistencyLevel>(parse_result.read_consistency_type_);
......
...@@ -627,6 +627,7 @@ struct ObSqlParseResult ...@@ -627,6 +627,7 @@ struct ObSqlParseResult
bool has_explain() const { return has_explain_; } bool has_explain() const { return has_explain_; }
bool has_simple_route_info() const { return has_simple_route_info_; } bool has_simple_route_info() const { return has_simple_route_info_; }
bool has_shard_comment() const { return has_shard_comment_; } bool has_shard_comment() const { return has_shard_comment_; }
bool has_anonymous_block() const { return has_anonymous_block_; }
bool is_simple_route_info_valid() const { return route_info_.is_valid(); } bool is_simple_route_info_valid() const { return route_info_.is_valid(); }
...@@ -724,6 +725,7 @@ struct ObSqlParseResult ...@@ -724,6 +725,7 @@ struct ObSqlParseResult
has_row_count_ = other.has_row_count_; has_row_count_ = other.has_row_count_;
has_explain_ = other.has_explain_; has_explain_ = other.has_explain_;
has_simple_route_info_ = other.has_simple_route_info_; has_simple_route_info_ = other.has_simple_route_info_;
has_anonymous_block_ = other.has_anonymous_block_;
stmt_type_ = other.stmt_type_; stmt_type_ = other.stmt_type_;
hint_query_timeout_ = other.hint_query_timeout_; hint_query_timeout_ = other.hint_query_timeout_;
parsed_length_ = other.parsed_length_; parsed_length_ = other.parsed_length_;
...@@ -814,6 +816,7 @@ private: ...@@ -814,6 +816,7 @@ private:
bool has_simple_route_info_; bool has_simple_route_info_;
bool has_shard_comment_; bool has_shard_comment_;
bool is_dual_request_; bool is_dual_request_;
bool has_anonymous_block_;
ObProxyBasicStmtType stmt_type_; ObProxyBasicStmtType stmt_type_;
int64_t hint_query_timeout_; int64_t hint_query_timeout_;
int64_t parsed_length_; // next parser can starts with (orig_sql + parsed_length_) int64_t parsed_length_; // next parser can starts with (orig_sql + parsed_length_)
...@@ -913,6 +916,7 @@ inline void ObSqlParseResult::reset(bool is_reset_origin_db_table /* true */) ...@@ -913,6 +916,7 @@ inline void ObSqlParseResult::reset(bool is_reset_origin_db_table /* true */)
has_simple_route_info_ = false; has_simple_route_info_ = false;
has_shard_comment_ = false; has_shard_comment_ = false;
is_dual_request_ = false; is_dual_request_ = false;
has_anonymous_block_ = false;
stmt_type_ = OBPROXY_T_INVALID; stmt_type_ = OBPROXY_T_INVALID;
cmd_sub_type_ = OBPROXY_T_SUB_INVALID; cmd_sub_type_ = OBPROXY_T_SUB_INVALID;
cmd_err_type_ = OBPROXY_T_ERR_INVALID; cmd_err_type_ = OBPROXY_T_ERR_INVALID;
......
...@@ -404,6 +404,7 @@ typedef struct _ObProxyParseResult ...@@ -404,6 +404,7 @@ typedef struct _ObProxyParseResult
bool has_row_count_; bool has_row_count_;
bool has_explain_; bool has_explain_;
bool has_simple_route_info_; bool has_simple_route_info_;
bool has_anonymous_block_;
ObProxyBasicStmtType stmt_type_; ObProxyBasicStmtType stmt_type_;
ObProxyBasicStmtSubType sub_stmt_type_; //for sharding ObProxyBasicStmtSubType sub_stmt_type_; //for sharding
int64_t stmt_count_; int64_t stmt_count_;
......
...@@ -193,6 +193,15 @@ do {\ ...@@ -193,6 +193,15 @@ do {\
}\ }\
return word_type;\ return word_type;\
} while (0); } while (0);
#define SET_HAS_ANONYMOUS_BLOCK() \
do { \
ObProxyParseResult *p = yyget_extra(yyscanner);\
if (OB_NOTNULL(p)) {\
if (OBPROXY_T_INVALID == p->cur_stmt_type_) {\
p->has_anonymous_block_ = true;\
} \
}\
} while (0);
#define PUSH_STATE(state) \ #define PUSH_STATE(state) \
{ yy_push_state(state, yyscanner); } { yy_push_state(state, yyscanner); }
...@@ -249,6 +258,7 @@ do {\ ...@@ -249,6 +258,7 @@ do {\
%x bt %x bt
%x bt_in_expr %x bt_in_expr
%x in_expr %x in_expr
%x in_anonymous_block
%x in_subquery %x in_subquery
%x in_no_select_query %x in_no_select_query
%x prepare %x prepare
...@@ -352,12 +362,14 @@ REPLACE { SET_DML_STMT(OBPROXY_T_REPLACE); return REPLACE; } ...@@ -352,12 +362,14 @@ REPLACE { SET_DML_STMT(OBPROXY_T_REPLACE); return REPLACE; }
MERGE { SET_DML_STMT(OBPROXY_T_MERGE); return MERGE; } MERGE { SET_DML_STMT(OBPROXY_T_MERGE); return MERGE; }
SHOW { SET_BASIC_STMT(OBPROXY_T_SHOW); return SHOW; } SHOW { SET_BASIC_STMT(OBPROXY_T_SHOW); return SHOW; }
XA { RETURN_NON_RESERVED_KEYWORD(XA); } XA { RETURN_NON_RESERVED_KEYWORD(XA); }
BEGIN { RETURN_NON_RESERVED_KEYWORD(BEGI); } /* if begin is for starting transaction, will set has_anonymous_block = false in yacc */
BEGIN { SET_HAS_ANONYMOUS_BLOCK(); RETURN_NON_RESERVED_KEYWORD(BEGI); }
START { RETURN_NON_RESERVED_KEYWORD(START); } START { RETURN_NON_RESERVED_KEYWORD(START); }
COMMIT { SET_BASIC_STMT(OBPROXY_T_COMMIT); RETURN_IGNORED_WORD(); } COMMIT { SET_BASIC_STMT(OBPROXY_T_COMMIT); RETURN_IGNORED_WORD(); }
ROLLBACK { SET_BASIC_STMT(OBPROXY_T_ROLLBACK); RETURN_IGNORED_WORD(); } ROLLBACK { SET_BASIC_STMT(OBPROXY_T_ROLLBACK); RETURN_IGNORED_WORD(); }
SET { SET_BASIC_STMT(OBPROXY_T_SET); PUSH_STATE_IF_NOT_ICMD(set_expr); return SET; } SET { SET_BASIC_STMT(OBPROXY_T_SET); PUSH_STATE_IF_NOT_ICMD(set_expr); return SET; }
CALL { SET_BASIC_STMT(OBPROXY_T_CALL); return CALL; } CALL { SET_BASIC_STMT(OBPROXY_T_CALL); return CALL; }
DECLARE { SET_HAS_ANONYMOUS_BLOCK(); PUSH_STATE(in_anonymous_block); }
WHEN { ObProxyParseResult *p = yyget_extra(yyscanner); WHEN { ObProxyParseResult *p = yyget_extra(yyscanner);
if (OB_NOTNULL(p)) { if (OB_NOTNULL(p)) {
if (OBPROXY_T_INSERT == p->cur_stmt_type_) if (OBPROXY_T_INSERT == p->cur_stmt_type_)
...@@ -1030,6 +1042,9 @@ LAST_INSERT_ID { SET_LAST_INSERT_ID(); RETURN_NON_RESERVED_KEYWORD(NAME_OB); } ...@@ -1030,6 +1042,9 @@ LAST_INSERT_ID { SET_LAST_INSERT_ID(); RETURN_NON_RESERVED_KEYWORD(NAME_OB); }
<prepare>{dquote} { POP_STATE(); } <prepare>{dquote} { POP_STATE(); }
<prepare>{quote} { POP_STATE(); } <prepare>{quote} { POP_STATE(); }
<in_anonymous_block>"BEGIN" { POP_STATE(); return BEGI;}
<in_anonymous_block>. {}
<<EOF>> { return END_P; } <<EOF>> { return END_P; }
. { RETURN_IGNORED_WORD(); } . { RETURN_IGNORED_WORD(); }
%% %%
......
...@@ -1007,7 +1007,10 @@ opt_count: /* empty */ ...@@ -1007,7 +1007,10 @@ opt_count: /* empty */
| COUNT '*' | COUNT '*'
/* begin stmt */ /* begin stmt */
begin_stmt: BEGI { result->cur_stmt_type_ = OBPROXY_T_BEGIN; } begin_stmt: BEGI {
result->has_anonymous_block_ = false ;
result->cur_stmt_type_ = OBPROXY_T_BEGIN;
}
| START TRANSACTION opt_transaction_characteristics { result->cur_stmt_type_ = OBPROXY_T_BEGIN; } | START TRANSACTION opt_transaction_characteristics { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
| XA BEGI NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; } | XA BEGI NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
| XA START NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; } | XA START NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
......
...@@ -235,12 +235,13 @@ void obproxyfree (void * ,yyscan_t yyscanner ); ...@@ -235,12 +235,13 @@ void obproxyfree (void * ,yyscan_t yyscanner );
#define bt 13 #define bt 13
#define bt_in_expr 14 #define bt_in_expr 14
#define in_expr 15 #define in_expr 15
#define in_subquery 16 #define in_anonymous_block 16
#define in_no_select_query 17 #define in_subquery 17
#define prepare 18 #define in_no_select_query 18
#define insert_all_expr 19 #define prepare 19
#define set_expr 20 #define insert_all_expr 20
#define show_topology 21 #define set_expr 21
#define show_topology 22
#endif #endif
...@@ -358,9 +359,9 @@ extern int obproxylex \ ...@@ -358,9 +359,9 @@ extern int obproxylex \
#undef YY_DECL #undef YY_DECL
#endif #endif
#line 1035 "ob_proxy_parser.l" #line 1050 "ob_proxy_parser.l"
#line 365 "ob_proxy_parser_lex.h" #line 366 "ob_proxy_parser_lex.h"
#undef obproxyIN_HEADER #undef obproxyIN_HEADER
#endif /* obproxyHEADER_H */ #endif /* obproxyHEADER_H */
...@@ -1088,14 +1088,14 @@ static const yytype_uint16 yyrline[] = ...@@ -1088,14 +1088,14 @@ static const yytype_uint16 yyrline[] =
941, 942, 946, 947, 950, 952, 953, 954, 955, 959, 941, 942, 946, 947, 950, 952, 953, 954, 955, 959,
960, 963, 965, 966, 967, 971, 972, 973, 977, 978, 960, 963, 965, 966, 967, 971, 972, 973, 977, 978,
979, 983, 987, 991, 992, 996, 997, 1001, 1002, 1003, 979, 983, 987, 991, 992, 996, 997, 1001, 1002, 1003,
1006, 1007, 1010, 1011, 1012, 1013, 1015, 1016, 1018, 1019, 1006, 1007, 1010, 1014, 1015, 1016, 1018, 1019, 1021, 1022,
1022, 1023, 1026, 1032, 1035, 1037, 1038, 1039, 1041, 1046, 1025, 1026, 1029, 1035, 1038, 1040, 1041, 1042, 1044, 1049,
1049, 1053, 1057, 1062, 1066, 1072, 1073, 1074, 1075, 1076, 1052, 1056, 1060, 1065, 1069, 1075, 1076, 1077, 1078, 1079,
1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089,
1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099,
1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109,
1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1117, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1120,
1118 1121
}; };
#endif #endif
...@@ -4026,7 +4026,10 @@ yyreduce: ...@@ -4026,7 +4026,10 @@ yyreduce:
case 352: case 352:
{ result->cur_stmt_type_ = OBPROXY_T_BEGIN; ;} {
result->has_anonymous_block_ = false ;
result->cur_stmt_type_ = OBPROXY_T_BEGIN;
;}
break; break;
case 353: case 353:
......
...@@ -6322,7 +6322,8 @@ int ObMysqlSM::setup_server_request_send() ...@@ -6322,7 +6322,8 @@ int ObMysqlSM::setup_server_request_send()
// Attention: // Attention:
// 1. if send begin or start, think as in trans // 1. if send begin or start, think as in trans
// 2. if autocommit = 0, first SQL think as not in trans // 2. if autocommit = 0, first SQL think as not in trans
} else if (trans_state_.trans_info_.client_request_.get_parse_result().is_call_stmt()) { } else if (trans_state_.trans_info_.client_request_.get_parse_result().is_call_stmt()
|| trans_state_.trans_info_.client_request_.get_parse_result().has_anonymous_block()) {
if (trans_state_.is_hold_start_trans_ || ObMysqlTransact::is_in_trans(trans_state_)) { if (trans_state_.is_hold_start_trans_ || ObMysqlTransact::is_in_trans(trans_state_)) {
set_server_trx_timeout(); set_server_trx_timeout();
} else { } else {
......
...@@ -4277,8 +4277,9 @@ inline void ObMysqlTransact::handle_server_failed(ObTransState &s) ...@@ -4277,8 +4277,9 @@ inline void ObMysqlTransact::handle_server_failed(ObTransState &s)
case -OB_ERR_READ_ONLY: { case -OB_ERR_READ_ONLY: {
if (ZONE_TYPE_READONLY == s.pll_info_.route_.cur_chosen_server_.zone_type_ if (ZONE_TYPE_READONLY == s.pll_info_.route_.cur_chosen_server_.zone_type_
|| ZONE_TYPE_ENCRYPTION == s.pll_info_.route_.cur_chosen_server_.zone_type_) { || ZONE_TYPE_ENCRYPTION == s.pll_info_.route_.cur_chosen_server_.zone_type_) {
LOG_WARN("zone is readonly, but server tell error response, " LOG_WARN("zone is readonly or encryption, but server tell error response, "
"maybe this new server do not support old agreement, try next server", "maybe this new server do not support old agreement, try next server",
"zone_type", zone_type_to_str(s.pll_info_.route_.cur_chosen_server_.zone_type_),
"origin_name", s.pll_info_.te_name_, "origin_name", s.pll_info_.te_name_,
"sql_cmd", get_mysql_cmd_str(s.trans_info_.sql_cmd_), "sql_cmd", get_mysql_cmd_str(s.trans_info_.sql_cmd_),
"sql", s.trans_info_.client_request_.get_print_sql(), "sql", s.trans_info_.client_request_.get_print_sql(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册