Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/obproxy/obutils/ob_proxy_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Collaborator

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

DEF_STR_LIST(weak_read_user_list, "", "weak read only for list of users, format user1;user2", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_USER);

//ldc
DEF_STR(proxy_idc_name, "", "idc name for proxy ldc route. If is empty or invalid, treat as do not use ldc. User session vars 'proxy_session_ldc' can cover it", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_SYS);

Expand Down
19 changes: 18 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,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 ;
Copy link
Collaborator

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

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; 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)){
Copy link

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

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