Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
obproxy
提交
90a9d6d7
O
obproxy
项目概览
oceanbase
/
obproxy
1 年多 前同步成功
通知
11
Star
100
Fork
70
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obproxy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
90a9d6d7
编写于
6月 03, 2021
作者:
W
wgs13579
提交者:
guangshu.wgs
6月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize timeout of anonymous block
上级
93b2e020
变更
10
展开全部
显示空白变更内容
内联
并排
Showing
10 changed file
with
2572 addition
and
2488 deletion
+2572
-2488
src/obproxy/obutils/ob_proxy_sql_parser.cpp
src/obproxy/obutils/ob_proxy_sql_parser.cpp
+1
-0
src/obproxy/obutils/ob_proxy_sql_parser.h
src/obproxy/obutils/ob_proxy_sql_parser.h
+4
-0
src/obproxy/opsql/parser/ob_proxy_parse_result.h
src/obproxy/opsql/parser/ob_proxy_parse_result.h
+1
-0
src/obproxy/opsql/parser/ob_proxy_parser.l
src/obproxy/opsql/parser/ob_proxy_parser.l
+16
-1
src/obproxy/opsql/parser/ob_proxy_parser.y
src/obproxy/opsql/parser/ob_proxy_parser.y
+4
-1
src/obproxy/opsql/parser/ob_proxy_parser_lex.c
src/obproxy/opsql/parser/ob_proxy_parser_lex.c
+2521
-2467
src/obproxy/opsql/parser/ob_proxy_parser_lex.h
src/obproxy/opsql/parser/ob_proxy_parser_lex.h
+9
-8
src/obproxy/opsql/parser/ob_proxy_parser_tab.c
src/obproxy/opsql/parser/ob_proxy_parser_tab.c
+12
-9
src/obproxy/proxy/mysql/ob_mysql_sm.cpp
src/obproxy/proxy/mysql/ob_mysql_sm.cpp
+2
-1
src/obproxy/proxy/mysql/ob_mysql_transact.cpp
src/obproxy/proxy/mysql/ob_mysql_transact.cpp
+2
-1
未找到文件。
src/obproxy/obutils/ob_proxy_sql_parser.cpp
浏览文件 @
90a9d6d7
...
...
@@ -559,6 +559,7 @@ int ObSqlParseResult::load_result(const ObProxyParseResult &parse_result,
has_shard_comment_
=
parse_result
.
has_shard_comment_
;
has_last_insert_id_
=
parse_result
.
has_last_insert_id_
;
hint_query_timeout_
=
parse_result
.
query_timeout_
;
has_anonymous_block_
=
parse_result
.
has_anonymous_block_
;
stmt_type_
=
parse_result
.
stmt_type_
;
cmd_sub_type_
=
parse_result
.
sub_stmt_type_
;
hint_consistency_level_
=
static_cast
<
ObConsistencyLevel
>
(
parse_result
.
read_consistency_type_
);
...
...
src/obproxy/obutils/ob_proxy_sql_parser.h
浏览文件 @
90a9d6d7
...
...
@@ -627,6 +627,7 @@ struct ObSqlParseResult
bool
has_explain
()
const
{
return
has_explain_
;
}
bool
has_simple_route_info
()
const
{
return
has_simple_route_info_
;
}
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
();
}
...
...
@@ -724,6 +725,7 @@ struct ObSqlParseResult
has_row_count_
=
other
.
has_row_count_
;
has_explain_
=
other
.
has_explain_
;
has_simple_route_info_
=
other
.
has_simple_route_info_
;
has_anonymous_block_
=
other
.
has_anonymous_block_
;
stmt_type_
=
other
.
stmt_type_
;
hint_query_timeout_
=
other
.
hint_query_timeout_
;
parsed_length_
=
other
.
parsed_length_
;
...
...
@@ -814,6 +816,7 @@ private:
bool
has_simple_route_info_
;
bool
has_shard_comment_
;
bool
is_dual_request_
;
bool
has_anonymous_block_
;
ObProxyBasicStmtType
stmt_type_
;
int64_t
hint_query_timeout_
;
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 */)
has_simple_route_info_
=
false
;
has_shard_comment_
=
false
;
is_dual_request_
=
false
;
has_anonymous_block_
=
false
;
stmt_type_
=
OBPROXY_T_INVALID
;
cmd_sub_type_
=
OBPROXY_T_SUB_INVALID
;
cmd_err_type_
=
OBPROXY_T_ERR_INVALID
;
...
...
src/obproxy/opsql/parser/ob_proxy_parse_result.h
浏览文件 @
90a9d6d7
...
...
@@ -404,6 +404,7 @@ typedef struct _ObProxyParseResult
bool
has_row_count_
;
bool
has_explain_
;
bool
has_simple_route_info_
;
bool
has_anonymous_block_
;
ObProxyBasicStmtType
stmt_type_
;
ObProxyBasicStmtSubType
sub_stmt_type_
;
//for sharding
int64_t
stmt_count_
;
...
...
src/obproxy/opsql/parser/ob_proxy_parser.l
浏览文件 @
90a9d6d7
...
...
@@ -193,6 +193,15 @@ do {\
}\
return word_type;\
} 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) \
{ yy_push_state(state, yyscanner); }
...
...
@@ -249,6 +258,7 @@ do {\
%x bt
%x bt_in_expr
%x in_expr
%x in_anonymous_block
%x in_subquery
%x in_no_select_query
%x prepare
...
...
@@ -352,12 +362,14 @@ REPLACE { SET_DML_STMT(OBPROXY_T_REPLACE); return REPLACE; }
MERGE { SET_DML_STMT(OBPROXY_T_MERGE); return MERGE; }
SHOW { SET_BASIC_STMT(OBPROXY_T_SHOW); return SHOW; }
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); }
COMMIT { SET_BASIC_STMT(OBPROXY_T_COMMIT); 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; }
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);
if (OB_NOTNULL(p)) {
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); }
<prepare>{dquote} { POP_STATE(); }
<prepare>{quote} { POP_STATE(); }
<in_anonymous_block>"BEGIN" { POP_STATE(); return BEGI;}
<in_anonymous_block>. {}
<<EOF>> { return END_P; }
. { RETURN_IGNORED_WORD(); }
%%
...
...
src/obproxy/opsql/parser/ob_proxy_parser.y
浏览文件 @
90a9d6d7
...
...
@@ -1007,7 +1007,10 @@ opt_count: /* empty */
| COUNT '*'
/* 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; }
| XA BEGI NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
| XA START NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
...
...
src/obproxy/opsql/parser/ob_proxy_parser_lex.c
浏览文件 @
90a9d6d7
此差异已折叠。
点击以展开。
src/obproxy/opsql/parser/ob_proxy_parser_lex.h
浏览文件 @
90a9d6d7
...
...
@@ -235,12 +235,13 @@ void obproxyfree (void * ,yyscan_t yyscanner );
#define bt 13
#define bt_in_expr 14
#define in_expr 15
#define in_subquery 16
#define in_no_select_query 17
#define prepare 18
#define insert_all_expr 19
#define set_expr 20
#define show_topology 21
#define in_anonymous_block 16
#define in_subquery 17
#define in_no_select_query 18
#define prepare 19
#define insert_all_expr 20
#define set_expr 21
#define show_topology 22
#endif
...
...
@@ -358,9 +359,9 @@ extern int obproxylex \
#undef YY_DECL
#endif
#line 10
35
"ob_proxy_parser.l"
#line 10
50
"ob_proxy_parser.l"
#line 36
5
"ob_proxy_parser_lex.h"
#line 36
6
"ob_proxy_parser_lex.h"
#undef obproxyIN_HEADER
#endif
/* obproxyHEADER_H */
src/obproxy/opsql/parser/ob_proxy_parser_tab.c
浏览文件 @
90a9d6d7
...
...
@@ -1088,14 +1088,14 @@ static const yytype_uint16 yyrline[] =
941
,
942
,
946
,
947
,
950
,
952
,
953
,
954
,
955
,
959
,
960
,
963
,
965
,
966
,
967
,
971
,
972
,
973
,
977
,
978
,
979
,
983
,
987
,
991
,
992
,
996
,
997
,
1001
,
1002
,
1003
,
1006
,
1007
,
1010
,
101
1
,
1012
,
1013
,
1015
,
1016
,
1018
,
1019
,
102
2
,
1023
,
1026
,
1032
,
1035
,
1037
,
1038
,
1039
,
1041
,
1046
,
10
49
,
1053
,
1057
,
1062
,
1066
,
1072
,
1073
,
1074
,
1075
,
1076
,
10
77
,
1078
,
1079
,
1080
,
1081
,
1082
,
1083
,
1084
,
1085
,
1086
,
10
87
,
1088
,
1089
,
1090
,
1091
,
1092
,
1093
,
1094
,
1095
,
1096
,
1
097
,
1098
,
1099
,
1100
,
1101
,
1102
,
1103
,
1104
,
1105
,
1106
,
11
07
,
1108
,
1109
,
1110
,
1111
,
1112
,
1113
,
1114
,
1115
,
1117
,
11
18
1006
,
1007
,
1010
,
101
4
,
1015
,
1016
,
1018
,
1019
,
1021
,
1022
,
102
5
,
1026
,
1029
,
1035
,
1038
,
1040
,
1041
,
1042
,
1044
,
1049
,
10
52
,
1056
,
1060
,
1065
,
1069
,
1075
,
1076
,
1077
,
1078
,
1079
,
10
80
,
1081
,
1082
,
1083
,
1084
,
1085
,
1086
,
1087
,
1088
,
1089
,
10
90
,
1091
,
1092
,
1093
,
1094
,
1095
,
1096
,
1097
,
1098
,
1099
,
1
100
,
1101
,
1102
,
1103
,
1104
,
1105
,
1106
,
1107
,
1108
,
1109
,
11
10
,
1111
,
1112
,
1113
,
1114
,
1115
,
1116
,
1117
,
1118
,
1120
,
11
21
};
#endif
...
...
@@ -4026,7 +4026,10 @@ yyreduce:
case
352
:
{
result
->
cur_stmt_type_
=
OBPROXY_T_BEGIN
;
;}
{
result
->
has_anonymous_block_
=
false
;
result
->
cur_stmt_type_
=
OBPROXY_T_BEGIN
;
;}
break
;
case
353
:
...
...
src/obproxy/proxy/mysql/ob_mysql_sm.cpp
浏览文件 @
90a9d6d7
...
...
@@ -6322,7 +6322,8 @@ int ObMysqlSM::setup_server_request_send()
// Attention:
// 1. if send begin or start, think as 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_
))
{
set_server_trx_timeout
();
}
else
{
...
...
src/obproxy/proxy/mysql/ob_mysql_transact.cpp
浏览文件 @
90a9d6d7
...
...
@@ -4277,8 +4277,9 @@ inline void ObMysqlTransact::handle_server_failed(ObTransState &s)
case
-
OB_ERR_READ_ONLY
:
{
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_
)
{
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"
,
"zone_type"
,
zone_type_to_str
(
s
.
pll_info_
.
route_
.
cur_chosen_server_
.
zone_type_
),
"origin_name"
,
s
.
pll_info_
.
te_name_
,
"sql_cmd"
,
get_mysql_cmd_str
(
s
.
trans_info_
.
sql_cmd_
),
"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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录