提交 f8e15a35 编写于 作者: F ftai

add: add variable weak_read_user_list

上级 bacd5fac
......@@ -486,6 +486,11 @@ public:
DEF_BOOL(enable_read_write_split, "false", "if enabled, use read write split mode", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_SYS);
DEF_BOOL(enable_transaction_split, "false", "if enabled, support transaction split", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_SYS);
// user list
DEF_STR_LIST(weak_read_user_list, "", "weak read for list of users, format user1;user2", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_USER);
// DEF_STR_LIST(read_only_user_list, "", "read only for list of users, format user1;user2", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_USER);
// binlog service
DEF_STR(binlog_service_ip, "", "binlog service ip, format ip1:sql_port1", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_SYS);
DEF_BOOL(enable_binlog_service, "false", "if enabled, obproxy will send binlog request to OBLogProxy", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_SYS);
......
......@@ -6131,6 +6131,24 @@ int ObMysqlTransact::ObTransState::get_config_item(const ObString& cluster_name,
}
if (OB_SUCC(ret)) {
bool is_weak_read_user = false;
int64_t total_size = get_global_proxy_config().weak_read_user_list.size();
if (OB_UNLIKELY(total_size > 0)) {
ObMysqlAuthRequest &auth_req = session_info.get_login_req();
ObHSRResult &hsr = auth_req.get_hsr_result();
char user_buf[MAX_VALUE_LENGTH];
for (int64_t i = 0; OB_SUCC(ret) && i < total_size; ++i) {
user_buf[0] = '\0';
if (OB_FAIL(get_global_proxy_config().weak_read_user_list.get(i, user_buf, static_cast<int64_t>(sizeof(user_buf))))) {
LOG_WARN("get weak read user list variables failed", K(ret));
} else{
if (hsr.response_.get_username().prefix_match(user_buf)){
is_weak_read_user = true;
break;
}
}
}
}
ObConfigIntItem int_item;
if (OB_FAIL(get_global_config_processor().get_proxy_config_int_item(
addr, cluster_name, tenant_name, "obproxy_read_consistency", int_item))) {
......@@ -6139,10 +6157,10 @@ int ObMysqlTransact::ObTransState::get_config_item(const ObString& cluster_name,
bool is_request_follower = (RequestFollower == int_item.get_value());
bool is_sys_var_update = (session_info.is_request_follower_user() != is_request_follower);
session_info.set_is_request_follower_user(is_request_follower);
if (is_sys_var_update) {
if (is_sys_var_update || is_weak_read_user) {
ObString ob_read_consistency("ob_read_consistency");
ObString weak;
if (session_info.is_request_follower_user()) {
if (session_info.is_request_follower_user() || is_weak_read_user) {
weak = "2";
} else {
weak = "3";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册