HappenLee commented on code in PR #25701:
URL: https://github.com/apache/doris/pull/25701#discussion_r1369487494


##########
be/src/vec/sink/writer/vtablet_writer.cpp:
##########
@@ -996,28 +995,30 @@ void VTabletWriter::_send_batch_process() {
     SCOPED_ATTACH_TASK(_state);
     SCOPED_CONSUME_MEM_TRACKER(_mem_tracker);
 
-    bool had_effect = false;
     while (true) {
         // incremental open will temporarily make channels into abnormal 
state. stop checking when this.
         std::unique_lock<std::mutex> l(_stop_check_channel);
 
         int running_channels_num = 0;
+        int opened_nodes = 0;
         for (const auto& index_channel : _channels) {
             index_channel->for_each_node_channel([&running_channels_num,
                                                   this](const 
std::shared_ptr<VNodeChannel>& ch) {
+                // if this channel all completed(cancelled), got 0. else 1.
                 running_channels_num +=
                         ch->try_send_and_fetch_status(_state, 
this->_send_batch_thread_pool_token);
             });
+            opened_nodes += index_channel->num_node_channels();
         }
 
-        // if there is no channel, maybe auto partition table. so check does 
there have had running channels ever.
-        if (running_channels_num == 0 && had_effect) {
+        // auto partition table may have no node channel temporarily. wait to 
open.
+        // for auto partition tables, there's a situation: we haven't open any 
node channel but decide to cancel the task.
+        //  then the judge will never be true because opened_nodes won't 
increase. so we have to specially check wether we called close.
+        if ((opened_nodes != 0 && running_channels_num == 0) || _try_close) {

Review Comment:
   review the `_try_close` the logic



-- 
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