github-actions[bot] commented on code in PR #45232:
URL: https://github.com/apache/doris/pull/45232#discussion_r1877508184
##########
be/src/runtime/fragment_mgr.cpp:
##########
@@ -639,116 +638,107 @@ Status FragmentMgr::start_query_execution(const
PExecPlanFragmentStartRequest* r
void FragmentMgr::remove_pipeline_context(
std::shared_ptr<pipeline::PipelineFragmentContext> f_context) {
- {
- std::lock_guard<std::mutex> lock(_lock);
- auto query_id = f_context->get_query_id();
- int64 now = duration_cast<std::chrono::milliseconds>(
-
std::chrono::system_clock::now().time_since_epoch())
- .count();
- g_fragment_executing_count << -1;
- g_fragment_last_active_time.set_value(now);
- // this log will show when a query is really finished in BEs
- LOG_INFO("Removing query {} fragment {}", print_id(query_id),
f_context->get_fragment_id());
- _pipeline_map.erase({query_id, f_context->get_fragment_id()});
- }
+ auto query_id = f_context->get_query_id();
+ int64 now = duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch())
+ .count();
+ g_fragment_executing_count << -1;
+ g_fragment_last_active_time.set_value(now);
+
+ std::unique_lock lock(_pipeline_map_mutex);
+ _pipeline_map.erase({query_id, f_context->get_fragment_id()});
}
-std::shared_ptr<QueryContext> FragmentMgr::_get_or_erase_query_ctx(const
TUniqueId& query_id) {
+std::shared_ptr<QueryContext> FragmentMgr::get_query_ctx(const TUniqueId&
query_id) {
+ std::shared_lock lock(_query_ctx_map_mutex);
auto search = _query_ctx_map.find(query_id);
if (search != _query_ctx_map.end()) {
if (auto q_ctx = search->second.lock()) {
return q_ctx;
- } else {
- LOG(WARNING) << "Query context (query id = " << print_id(query_id)
- << ") has been released.";
- _query_ctx_map.erase(search);
- return nullptr;
}
}
return nullptr;
}
-std::shared_ptr<QueryContext> FragmentMgr::get_or_erase_query_ctx_with_lock(
- const TUniqueId& query_id) {
- std::unique_lock<std::mutex> lock(_lock);
- return _get_or_erase_query_ctx(query_id);
-}
-
-template <typename Params>
-Status FragmentMgr::_get_query_ctx(const Params& params, TUniqueId query_id,
bool pipeline,
- QuerySource query_source,
- std::shared_ptr<QueryContext>& query_ctx) {
+Status FragmentMgr::_get_or_create_query_ctx(const TPipelineFragmentParams&
params,
Review Comment:
warning: function '_get_or_create_query_ctx' has cognitive complexity of 69
(threshold 50) [readability-function-cognitive-complexity]
```cpp
Status FragmentMgr::_get_or_create_query_ctx(const TPipelineFragmentParams&
params,
^
```
<details>
<summary>Additional context</summary>
**be/src/runtime/fragment_mgr.cpp:666:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
DBUG_EXECUTE_IF("FragmentMgr._get_query_ctx.failed", {
^
```
**be/src/util/debug_points.h:36:** expanded from macro 'DBUG_EXECUTE_IF'
```cpp
if (UNLIKELY(config::enable_debug_points)) {
\
^
```
**be/src/runtime/fragment_mgr.cpp:666:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
DBUG_EXECUTE_IF("FragmentMgr._get_query_ctx.failed", {
^
```
**be/src/util/debug_points.h:38:** expanded from macro 'DBUG_EXECUTE_IF'
```cpp
if (dp) {
\
^
```
**be/src/runtime/fragment_mgr.cpp:674:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (params.is_simplified_param) {
^
```
**be/src/runtime/fragment_mgr.cpp:676:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
if (!query_ctx) {
^
```
**be/src/runtime/fragment_mgr.cpp:682:** +1, nesting level increased to 1
```cpp
} else {
^
```
**be/src/runtime/fragment_mgr.cpp:683:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
if (!query_ctx) {
^
```
**be/src/runtime/fragment_mgr.cpp:687:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
if (search != _query_ctx_map.end()) {
^
```
**be/src/runtime/fragment_mgr.cpp:691:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
if (!query_ctx) {
^
```
**be/src/runtime/fragment_mgr.cpp:705:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
RETURN_IF_ERROR(DescriptorTbl::create(&(query_ctx->obj_pool), params.desc_tbl,
^
```
**be/src/common/status.h:632:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/runtime/fragment_mgr.cpp:705:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
RETURN_IF_ERROR(DescriptorTbl::create(&(query_ctx->obj_pool), params.desc_tbl,
^
```
**be/src/common/status.h:634:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/runtime/fragment_mgr.cpp:708:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (params.__isset.file_scan_params) {
^
```
**be/src/runtime/fragment_mgr.cpp:714:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (params.__isset.resource_info) {
^
```
**be/src/runtime/fragment_mgr.cpp:722:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (params.__isset.workload_groups &&
!params.workload_groups.empty()) {
^
```
**be/src/runtime/fragment_mgr.cpp:722:** +1
```cpp
if (params.__isset.workload_groups &&
!params.workload_groups.empty()) {
^
```
**be/src/runtime/fragment_mgr.cpp:726:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
if (workload_group_ptr != nullptr) {
^
```
**be/src/runtime/fragment_mgr.cpp:727:** +6, including nesting penalty of 5,
nesting level increased to 6
```cpp
RETURN_IF_ERROR(workload_group_ptr->add_query(query_id, query_ctx));
^
```
**be/src/common/status.h:632:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/runtime/fragment_mgr.cpp:727:** +7, including nesting penalty of 6,
nesting level increased to 7
```cpp
RETURN_IF_ERROR(workload_group_ptr->add_query(query_id, query_ctx));
^
```
**be/src/common/status.h:634:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/runtime/fragment_mgr.cpp:728:** +6, including nesting penalty of 5,
nesting level increased to 6
```cpp
RETURN_IF_ERROR(query_ctx->set_workload_group(workload_group_ptr));
^
```
**be/src/common/status.h:632:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/runtime/fragment_mgr.cpp:728:** +7, including nesting penalty of 6,
nesting level increased to 7
```cpp
RETURN_IF_ERROR(query_ctx->set_workload_group(workload_group_ptr));
^
```
**be/src/common/status.h:634:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/runtime/fragment_mgr.cpp:731:** +1, nesting level increased to 5
```cpp
} else {
^
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]