github-actions[bot] commented on code in PR #39883:
URL: https://github.com/apache/doris/pull/39883#discussion_r1740633340


##########
be/src/pipeline/task_scheduler.cpp:
##########
@@ -187,15 +196,167 @@ void TaskScheduler::_do_work(size_t index) {
     }
 }
 
+void TaskScheduler::add_paused_task(PipelineTask* task) {
+    std::lock_guard<std::mutex> lock(_paused_queries_lock);
+    auto query_ctx_sptr = 
task->runtime_state()->get_query_ctx()->shared_from_this();
+    DCHECK(query_ctx_sptr != nullptr);
+    auto wg = query_ctx_sptr->workload_group();
+    auto&& [it, inserted] = 
_paused_queries_list[wg].emplace(std::move(query_ctx_sptr));
+    if (inserted) {
+        LOG(INFO) << "here insert one new paused query: " << 
print_id(it->get()->query_id());
+    }
+
+    _paused_queries_cv.notify_all();
+}
+
+/**
+ * Strategy 1: A revocable query should not have any running 
task(PipelineTask).
+ * strategy 2: If the workload group is below low water mark, we make all 
queries in this wg runnable.
+ * strategy 3: Pick the query which has the max revocable size to revoke 
memory.
+ * strategy 4: If all queries are not revocable and they all have not any 
running task,
+ *             we choose the max memory usage query to cancel.
+ */
+void TaskScheduler::_paused_queries_handler() {

Review Comment:
   warning: function '_paused_queries_handler' exceeds recommended 
size/complexity thresholds [readability-function-size]
   ```cpp
    */
                           ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/pipeline/task_scheduler.cpp:218:** 131 lines including whitespace 
and comments (threshold 80)
   ```cpp
    */
                           ^
   ```
   
   </details>
   



##########
be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:
##########
@@ -480,6 +517,7 @@ Status 
PartitionedHashJoinSinkOperatorX::_setup_internal_operator(RuntimeState*
 Status PartitionedHashJoinSinkOperatorX::sink(RuntimeState* state, 
vectorized::Block* in_block,

Review Comment:
   warning: function 'sink' has cognitive complexity of 74 (threshold 50) 
[readability-function-cognitive-complexity]
   ```cpp
   Status PartitionedHashJoinSinkOperatorX::sink(RuntimeState* state, 
vectorized::Block* in_block,
                                            ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:522:** +1, 
including nesting penalty of 0, nesting level increased to 1
   ```cpp
       if (!local_state._spill_status_ok) {
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:532:** +1, 
including nesting penalty of 0, nesting level increased to 1
   ```cpp
       if (rows == 0) {
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:533:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           if (eos) {
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:537:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (!need_to_spill) {
               ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:538:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   if 
(UNLIKELY(!local_state._shared_state->inner_runtime_state)) {
                   ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:539:** +5, 
including nesting penalty of 4, nesting level increased to 5
   ```cpp
                       RETURN_IF_ERROR(_setup_internal_operator(state));
                       ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:539:** +6, 
including nesting penalty of 5, nesting level increased to 6
   ```cpp
                       RETURN_IF_ERROR(_setup_internal_operator(state));
                       ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:541:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   
DBUG_EXECUTE_IF("fault_inject::partitioned_hash_join_sink::sink_eos", {
                   ^
   ```
   **be/src/util/debug_points.h:36:** expanded from macro 'DBUG_EXECUTE_IF'
   ```cpp
       if (UNLIKELY(config::enable_debug_points)) {                             
 \
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:541:** +5, 
including nesting penalty of 4, nesting level increased to 5
   ```cpp
                   
DBUG_EXECUTE_IF("fault_inject::partitioned_hash_join_sink::sink_eos", {
                   ^
   ```
   **be/src/util/debug_points.h:38:** expanded from macro 'DBUG_EXECUTE_IF'
   ```cpp
           if (dp) {                                                            
 \
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:546:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   RETURN_IF_ERROR(_inner_sink_operator->sink(
                   ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:546:** +5, 
including nesting penalty of 4, nesting level increased to 5
   ```cpp
                   RETURN_IF_ERROR(_inner_sink_operator->sink(
                   ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:552:** 
nesting level increased to 3
   ```cpp
                             [&](auto& block) {
                             ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:553:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                                 if (block) {
                                 ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:563:** +1, 
including nesting penalty of 0, nesting level increased to 1
   ```cpp
       if (need_to_spill) {
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:564:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           RETURN_IF_ERROR(local_state._partition_block(state, in_block, 0, 
rows));
           ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:564:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
           RETURN_IF_ERROR(local_state._partition_block(state, in_block, 0, 
rows));
           ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:565:** +1, 
nesting level increased to 1
   ```cpp
       } else {
         ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:566:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           if (UNLIKELY(!local_state._shared_state->inner_runtime_state)) {
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:567:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               RETURN_IF_ERROR(_setup_internal_operator(state));
               ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:567:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
               RETURN_IF_ERROR(_setup_internal_operator(state));
               ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:569:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           DBUG_EXECUTE_IF("fault_inject::partitioned_hash_join_sink::sink", {
           ^
   ```
   **be/src/util/debug_points.h:36:** expanded from macro 'DBUG_EXECUTE_IF'
   ```cpp
       if (UNLIKELY(config::enable_debug_points)) {                             
 \
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:569:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
           DBUG_EXECUTE_IF("fault_inject::partitioned_hash_join_sink::sink", {
           ^
   ```
   **be/src/util/debug_points.h:38:** expanded from macro 'DBUG_EXECUTE_IF'
   ```cpp
           if (dp) {                                                            
 \
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:574:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           RETURN_IF_ERROR(_inner_sink_operator->sink(
           ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:574:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
           RETURN_IF_ERROR(_inner_sink_operator->sink(
           ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:578:** +1, 
including nesting penalty of 0, nesting level increased to 1
   ```cpp
       if (eos) {
       ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:582:** 
nesting level increased to 2
   ```cpp
                         
local_state._shared_state->partitioned_build_blocks.end(), [&](auto& block) {
                                                                                
    ^
   ```
   **be/src/pipeline/exec/partitioned_hash_join_sink_operator.cpp:583:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
                             if (block) {
                             ^
   ```
   
   </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]

Reply via email to