Skip to content

Commit

Permalink
fix: show processlist segment fault
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-2023 authored and wy1433 committed Apr 16, 2024
1 parent ead6b54 commit 6689c78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/protocol/network_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,8 @@ void NetworkServer::client_conn_bvars_update() {
if (!sock->user_info || !sock->query_ctx) {
continue;
}
auto command = sock->query_ctx->mysql_cmd;
auto query_ctx = sock->get_query_ctx();
auto command = query_ctx->mysql_cmd;
client_cnt ++;
if (command != COM_SLEEP) {
running_sql_cnt ++;
Expand Down
8 changes: 5 additions & 3 deletions src/protocol/show_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,16 +1298,18 @@ bool ShowHelper::_show_processlist(const SmartSocket& client, const std::vector<
DB_FATAL("param invalid");
return false;
}
if (only_show_doing_sql && sock->query_ctx->sql.size() == 0) {
auto query_ctx = sock->get_query_ctx();
if (only_show_doing_sql && query_ctx->sql.size() == 0) {
continue;
}
DB_WARNING_CLIENT(sock, "processlist, free:%d", sock->is_free);
std::vector<std::string> row;
row.reserve(fields.size());
row.emplace_back(std::to_string(sock->conn_id));
row.emplace_back(sock->user_info->username);
row.emplace_back(sock->ip);
row.emplace_back(sock->current_db);
auto command = sock->query_ctx->mysql_cmd;
auto command = query_ctx->mysql_cmd;
if (command == COM_SLEEP) {
row.emplace_back("Sleep");
} else {
Expand All @@ -1322,7 +1324,7 @@ bool ShowHelper::_show_processlist(const SmartSocket& client, const std::vector<
if (command == COM_SLEEP) {
row.emplace_back("");
} else {
row.emplace_back(sock->query_ctx->sql);
row.emplace_back(query_ctx->sql);
}
rows.emplace_back(row);
}
Expand Down

0 comments on commit 6689c78

Please sign in to comment.