yiguolei commented on code in PR #20771: URL: https://github.com/apache/doris/pull/20771#discussion_r1233032702
########## be/src/vec/sink/vtablet_sink.cpp: ########## @@ -1393,133 +1385,226 @@ Status VOlapTableSink::send(RuntimeState* state, vectorized::Block* input_block, return Status::OK(); } -Status VOlapTableSink::close(RuntimeState* state, Status exec_status) { - if (_closed) { - return _close_status; +Status VOlapTableSink::_cancel_channel_and_check_intolerable_failure( + Status status, const std::string& err_msg, const std::shared_ptr<IndexChannel> ich, + const std::shared_ptr<VNodeChannel> nch) { + LOG(WARNING) << nch->channel_info() << ", close channel failed, err: " << err_msg; + ich->mark_as_failed(nch->node_id(), nch->host(), err_msg, -1); + // cancel the node channel in best effort + nch->cancel(err_msg); + + // check if index has intolerable failure + Status index_st = ich->check_intolerable_failure(); + if (!index_st.ok()) { + status = index_st; + } else if (Status st = ich->check_tablet_received_rows_consistency(); !st.ok()) { + status = st; + } + return status; +} + +void VOlapTableSink::_cancel_all_channel(Status status, const std::string& err_msg) { + for (auto channel : _channels) { + channel->for_each_node_channel([&status](const std::shared_ptr<VNodeChannel>& ch) { + ch->cancel(status.to_string()); + }); + } + LOG(INFO) << fmt::format( + "{}, close olap table sink. load_id={}, txn_id={}, canceled all node channels due to " + "error: {}", + err_msg, print_id(_load_id), _txn_id, status); +} + +bool VOlapTableSink::is_pending_finish() { + if (_pending_finish) { + bool pending_finish = false; + for (auto index_channel : _channels) { Review Comment: auto& -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org