Skip to content

Commit

Permalink
feat: enable weakly consistent read for users who connected the obproxy
Browse files Browse the repository at this point in the history
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
  • Loading branch information
justdba authored Mar 10, 2022
1 parent 9c10b58 commit 0340f2e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/obproxy/proxy/mysqllib/ob_proxy_session_info_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,25 @@ 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 ;
int64_t total_size = get_global_proxy_config().weak_read_user_list.size();
if (OB_UNLIKELY(total_size > 0)){
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) {
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;
}
}
}

if (client_info.is_request_follower_user() || get_global_proxy_config().enable_weak_read || is_weak_read_user) {
ObString ob_read_consistency("ob_read_consistency");
// 2 means WEAK for ob_read_consistency
ObString weak("2");
Expand Down

0 comments on commit 0340f2e

Please sign in to comment.