From 935d0eb1101b16a8dbaced93e7e809f377563b28 Mon Sep 17 00:00:00 2001 From: Vallish Pai Date: Wed, 21 Aug 2024 22:12:12 +0530 Subject: [PATCH] [cherry-pick](branch-2.1) [Bug](http-api) fix core dump on API check_rpc_channel coz exec_env not initialized #39519 (#39692) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …rpc_channel coz exec_env not initialized #39519 ## Proposed changes Issue Number: close #xxx backport #39519 #39520 --- .../http/action/check_rpc_channel_action.cpp | 1 + be/src/http/action/check_rpc_channel_action.h | 3 -- .../http/action/reset_rpc_channel_action.cpp | 3 +- be/src/http/action/reset_rpc_channel_action.h | 3 -- be/src/http/http_handler_with_auth.h | 4 ++- .../doris/regression/suite/Suite.groovy | 13 +++++++++ .../check_rpc_channel.groovy | 29 +++++++++++++++++++ 7 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 regression-test/suites/http_p0/check_rpc_channel/check_rpc_channel.groovy diff --git a/be/src/http/action/check_rpc_channel_action.cpp b/be/src/http/action/check_rpc_channel_action.cpp index 4949b21b8f51c9..7b98db510e52b0 100644 --- a/be/src/http/action/check_rpc_channel_action.cpp +++ b/be/src/http/action/check_rpc_channel_action.cpp @@ -39,6 +39,7 @@ namespace doris { CheckRPCChannelAction::CheckRPCChannelAction(ExecEnv* exec_env, TPrivilegeHier::type hier, TPrivilegeType::type type) : HttpHandlerWithAuth(exec_env, hier, type) {} + void CheckRPCChannelAction::handle(HttpRequest* req) { std::string req_ip = req->param("ip"); std::string req_port = req->param("port"); diff --git a/be/src/http/action/check_rpc_channel_action.h b/be/src/http/action/check_rpc_channel_action.h index 883180f02dfa49..07969c80f08e1d 100644 --- a/be/src/http/action/check_rpc_channel_action.h +++ b/be/src/http/action/check_rpc_channel_action.h @@ -31,8 +31,5 @@ class CheckRPCChannelAction : public HttpHandlerWithAuth { ~CheckRPCChannelAction() override = default; void handle(HttpRequest* req) override; - -private: - ExecEnv* _exec_env; }; } // namespace doris diff --git a/be/src/http/action/reset_rpc_channel_action.cpp b/be/src/http/action/reset_rpc_channel_action.cpp index b14c0f65e7f4f1..a9aa6ec950e0f2 100644 --- a/be/src/http/action/reset_rpc_channel_action.cpp +++ b/be/src/http/action/reset_rpc_channel_action.cpp @@ -34,7 +34,8 @@ namespace doris { ResetRPCChannelAction::ResetRPCChannelAction(ExecEnv* exec_env, TPrivilegeHier::type hier, TPrivilegeType::type type) - : HttpHandlerWithAuth(exec_env, hier, type), _exec_env(exec_env) {} + : HttpHandlerWithAuth(exec_env, hier, type) {} + void ResetRPCChannelAction::handle(HttpRequest* req) { std::string endpoints = req->param("endpoints"); if (iequal(endpoints, "all")) { diff --git a/be/src/http/action/reset_rpc_channel_action.h b/be/src/http/action/reset_rpc_channel_action.h index 16efecfee2646a..ba13c6be7c6333 100644 --- a/be/src/http/action/reset_rpc_channel_action.h +++ b/be/src/http/action/reset_rpc_channel_action.h @@ -31,8 +31,5 @@ class ResetRPCChannelAction : public HttpHandlerWithAuth { ~ResetRPCChannelAction() override = default; void handle(HttpRequest* req) override; - -private: - ExecEnv* _exec_env; }; } // namespace doris diff --git a/be/src/http/http_handler_with_auth.h b/be/src/http/http_handler_with_auth.h index 178971560c015b..894a3a81e50d28 100644 --- a/be/src/http/http_handler_with_auth.h +++ b/be/src/http/http_handler_with_auth.h @@ -51,8 +51,10 @@ class HttpHandlerWithAuth : public HttpHandler { return true; } -private: +protected: ExecEnv* _exec_env; + +private: TPrivilegeHier::type _hier; TPrivilegeType::type _type; }; diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy index edf6564fbba672..40ac53f93574cb 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy @@ -836,6 +836,19 @@ class Suite implements GroovyInterceptable { return; } + void getBackendIpHttpAndBrpcPort(Map backendId_to_backendIP, + Map backendId_to_backendHttpPort, Map backendId_to_backendBrpcPort) { + + List> backends = sql("show backends"); + for (List backend : backends) { + backendId_to_backendIP.put(String.valueOf(backend[0]), String.valueOf(backend[1])); + backendId_to_backendHttpPort.put(String.valueOf(backend[0]), String.valueOf(backend[4])); + backendId_to_backendBrpcPort.put(String.valueOf(backend[0]), String.valueOf(backend[5])); + } + return; + } + + int getTotalLine(String filePath) { def file = new File(filePath) int lines = 0; diff --git a/regression-test/suites/http_p0/check_rpc_channel/check_rpc_channel.groovy b/regression-test/suites/http_p0/check_rpc_channel/check_rpc_channel.groovy new file mode 100644 index 00000000000000..d79f71dac5cdd4 --- /dev/null +++ b/regression-test/suites/http_p0/check_rpc_channel/check_rpc_channel.groovy @@ -0,0 +1,29 @@ + +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite('check_rpc_channel') { + def backendId_to_backendIP = [:] + def backendId_to_backendHttpPort = [:] + def backendId_to_backendBrpcPort = [:] + + getBackendIpHttpAndBrpcPort(backendId_to_backendIP, backendId_to_backendHttpPort, backendId_to_backendBrpcPort); + for (int i=0;i