-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable weakly consistent read for users who connected this obproxy #21 #22
base: master
Are you sure you want to change the base?
Conversation
…oxy oceanbase#21 In the read-write separation scenario, a switch for the session-level enable weakly consistent read or for only the session-level enable weakly consistent to the specified user
oceanbase#21 In the read-write separation scenario, a switch for the session-level enable weakly consistent read or for only the session-level enable weakly consistent to the specified user
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)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码风格,else if放到上面右括号后面
ObMysqlAuthRequest &auth_req = client_info.get_login_req(); | ||
ObHSRResult &hsr = auth_req.get_hsr_result(); | ||
char user_buf[MAX_VALUE_LENGTH]; | ||
for (int64_t i = 0; i < total_size; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中间改为OB_SUCC(ret) && i < total_size
if (client_info.is_request_follower_user()) { | ||
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)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
){中间加个空格
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)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use this compare maybe misjudgment
@@ -1176,7 +1176,24 @@ int ObProxySessionInfoHandler::save_changed_session_info(ObClientSessionInfo &cl | |||
|
|||
// 6. handle vip for fllower replica in public cloud or handle config enable read only mode | |||
if (OB_SUCC(ret) && is_auth_request) { | |||
if (client_info.is_request_follower_user()) { | |||
bool is_weak_read_user = false ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic should be placed in the ObMysqlSM::analyze loginrequest function, where it is judged and called set_is_request_follower_user
@@ -306,6 +306,9 @@ class ObProxyConfig : public common::ObCommonConfig | |||
// proxy cmd | |||
DEF_INT(proxy_local_cmd, "0", "[0,]", "proxy local cmd type: 0->none(default), 1->exit, 2->restart, 3->commit, 4->rollback", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_MEMORY); | |||
|
|||
DEF_BOOL(enable_weak_read, "false", "weak read by default for all clients connected this proxy", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_USER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We expect three classes of instances:
Read-write, automatic read-write separation, read-only
So here should be read-only configuration items, including weak read and write prohibited
In the read-write separation scenario, a switch for the session-level enable weakly consistent read or for only the session-level enable weakly consistent to the specified user