Skip to content
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

[enhancement](util) print if using nereids planner when be coredump #31981 #41605

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions be/src/common/signal_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace doris::signal {
inline thread_local uint64 query_id_hi;
inline thread_local uint64 query_id_lo;
inline thread_local int64_t tablet_id = 0;
inline thread_local bool is_nereids = false;

namespace {

Expand Down Expand Up @@ -244,6 +245,9 @@ void DumpTimeInfo() {
formatter.AppendString("-");
formatter.AppendUint64(query_id_lo, 16);
formatter.AppendString(" ***\n");
formatter.AppendString("*** is nereids: ");
formatter.AppendUint64(is_nereids, 10);
formatter.AppendString(" ***\n");
formatter.AppendString("*** tablet id: ");
formatter.AppendUint64(tablet_id, 10);
formatter.AppendString(" ***\n");
Expand Down Expand Up @@ -436,6 +440,10 @@ inline void set_signal_task_id(TUniqueId tid) {
query_id_lo = tid.lo;
}

inline void set_signal_is_nereids(bool is_nereids_arg) {
is_nereids = is_nereids_arg;
}

inline void InstallFailureSignalHandler() {
// Build the sigaction struct.
struct sigaction sig_action;
Expand Down
3 changes: 2 additions & 1 deletion be/src/runtime/fragment_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ Status FragmentMgr::_get_query_ctx(const Params& params, TUniqueId query_id, boo
// This may be a first fragment request of the query.
// Create the query fragments context.
query_ctx = QueryContext::create_shared(params.fragment_num_on_host, _exec_env,
params.query_options);
params.query_options,params.is_nereids);
query_ctx->query_id = query_id;
RETURN_IF_ERROR(DescriptorTbl::create(&(query_ctx->obj_pool), params.desc_tbl,
&(query_ctx->desc_tbl)));
Expand Down Expand Up @@ -812,6 +812,7 @@ Status FragmentMgr::exec_plan_fragment(const TExecPlanFragmentParams& params,
std::shared_ptr<QueryContext> query_ctx;
bool pipeline_engine_enabled = params.query_options.__isset.enable_pipeline_engine &&
params.query_options.enable_pipeline_engine;

RETURN_IF_ERROR(
_get_query_ctx(params, params.params.query_id, pipeline_engine_enabled, query_ctx));
{
Expand Down
10 changes: 8 additions & 2 deletions be/src/runtime/query_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ class QueryContext {
ENABLE_FACTORY_CREATOR(QueryContext);

public:
QueryContext(int total_fragment_num, ExecEnv* exec_env, const TQueryOptions& query_options)
: fragment_num(total_fragment_num),
QueryContext(int total_fragment_num, ExecEnv* exec_env, const TQueryOptions& query_options,
bool is_nereids)
: _is_nereids(is_nereids),
fragment_num(total_fragment_num),
timeout_second(-1),
_exec_env(exec_env),
_runtime_filter_mgr(new RuntimeFilterMgr(TUniqueId(), this)),
Expand Down Expand Up @@ -222,12 +224,16 @@ class QueryContext {
public:
TUniqueId query_id;
DescriptorTbl* desc_tbl;

bool is_nereids() const { return _is_nereids; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'is_nereids' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
bool is_nereids() const { return _is_nereids; }
[[nodiscard]] bool is_nereids() const { return _is_nereids; }


bool set_rsc_info = false;
std::string user;
std::string group;
TNetworkAddress coord_addr;
TNetworkAddress current_connect_fe;
TQueryGlobals query_globals;
const bool _is_nereids;

/// In the current implementation, for multiple fragments executed by a query on the same BE node,
/// we store some common components in QueryContext, and save QueryContext in FragmentMgr.
Expand Down
4 changes: 4 additions & 0 deletions be/src/runtime/runtime_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "runtime/load_path_mgr.h"
#include "runtime/memory/mem_tracker_limiter.h"
#include "runtime/memory/thread_mem_tracker_mgr.h"
#include "runtime/query_context.h"
#include "runtime/runtime_filter_mgr.h"
#include "runtime/thread_context.h"
#include "util/timezone_utils.h"
Expand Down Expand Up @@ -390,4 +391,7 @@ bool RuntimeState::enable_page_cache() const {
(_query_options.__isset.enable_page_cache && _query_options.enable_page_cache);
}

bool RuntimeState::is_nereids() const {
return _query_ctx->is_nereids();
}
} // end namespace doris
3 changes: 3 additions & 0 deletions be/src/runtime/runtime_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ class RuntimeState {
: 0;
}


bool is_nereids() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'is_nereids' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
bool is_nereids() const;
[[nodiscard]] bool is_nereids() const;


private:
Status create_error_log_file();

Expand Down
1 change: 1 addition & 0 deletions be/src/runtime/thread_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ AttachTask::AttachTask(const std::shared_ptr<MemTrackerLimiter>& mem_tracker,
AttachTask::AttachTask(RuntimeState* runtime_state) {
SwitchBthreadLocal::switch_to_bthread_local();
signal::set_signal_task_id(runtime_state->query_id());
signal::set_signal_is_nereids(runtime_state->is_nereids());
thread_context()->attach_task(runtime_state->query_id(), runtime_state->fragment_instance_id(),
runtime_state->query_mem_tracker());
}
Expand Down
3 changes: 3 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,7 @@ List<TExecPlanFragmentParams> toThrift(int backendNum) {
for (int i = 0; i < instanceExecParams.size(); ++i) {
final FInstanceExecParam instanceExecParam = instanceExecParams.get(i);
TExecPlanFragmentParams params = new TExecPlanFragmentParams();
params.setIsNereids(ConnectContext.get() != null ? ConnectContext.get().getState().isNereids() : false);
params.setProtocolVersion(PaloInternalServiceVersion.V1);
params.setFragment(fragment.toThrift());
params.setDescTbl(descTable);
Expand Down Expand Up @@ -3302,6 +3303,8 @@ Map<TNetworkAddress, TPipelineFragmentParams> toTPipelineParams(int backendNum)
TPipelineFragmentParams params = new TPipelineFragmentParams();

// Set global param
params.setIsNereids(
ConnectContext.get() != null ? ConnectContext.get().getState().isNereids() : false);
params.setProtocolVersion(PaloInternalServiceVersion.V1);
params.setDescTbl(descTable);
params.setQueryId(queryId);
Expand Down
4 changes: 4 additions & 0 deletions gensrc/thrift/PaloInternalService.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ struct TExecPlanFragmentParams {
// scan node id -> scan range params, only for external file scan
24: optional map<Types.TPlanNodeId, PlanNodes.TFileScanRangeParams> file_scan_params

31: optional bool is_nereids = true;

32: optional Types.TNetworkAddress current_connect_fe
}

Expand Down Expand Up @@ -680,6 +682,8 @@ struct TPipelineFragmentParams {
// scan node id -> scan range params, only for external file scan
29: optional map<Types.TPlanNodeId, PlanNodes.TFileScanRangeParams> file_scan_params
43: optional Types.TNetworkAddress current_connect_fe

40: optional bool is_nereids = true;
}

struct TPipelineFragmentParamsList {
Expand Down
Loading