yiguolei commented on code in PR #69635:
URL: https://github.com/apache/doris/pull/69635#discussion_r4533479119


##########
be/src/exec/spill/spill_s3_file_writer.cpp:
##########
@@ -0,0 +1,127 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "exec/spill/spill_s3_file_writer.h"
+
+#include <chrono>
+#include <thread>
+#include <utility>
+
+#include "common/config.h"
+#include "exec/spill/spill_file.h"
+#include "exec/spill/spill_file_manager.h"
+#include "runtime/exec_env.h"
+#include "runtime/runtime_profile_counter_names.h"
+#include "runtime/workload_management/io_context.h"
+#include "util/defer_op.h"
+#include "util/stopwatch.hpp"
+#include "util/threadpool.h"
+
+namespace doris {
+
+SpillS3FileWriter::SpillS3FileWriter(const std::shared_ptr<SpillFile>& 
spill_file,
+                                     RuntimeState* state, RuntimeProfile* 
profile,
+                                     SpillDataDir* data_dir, 
io::FileSystemSPtr fs,
+                                     std::string spill_dir)
+        : SpillFileWriter(spill_file, state, profile, data_dir, std::move(fs),
+                          std::move(spill_dir)) {
+    RuntimeProfile* custom_profile = profile->get_child("CustomCounters");
+    _remote_upload_bytes = 
custom_profile->get_counter(profile::SPILL_REMOTE_UPLOAD_BYTES);
+    _remote_upload_timer = 
custom_profile->get_counter(profile::SPILL_REMOTE_UPLOAD_TIME);
+    _remote_upload_wait_timer = 
custom_profile->get_counter(profile::SPILL_REMOTE_UPLOAD_WAIT_TIME);
+}
+
+SpillS3FileWriter::~SpillS3FileWriter() {
+    // Base destruction cannot dispatch virtual hooks to this class. Close 
while the S3
+    // counters and queue admission hook are still alive, then let the base 
clear registration.
+    Status st = close();
+    if (!st.ok()) {
+        LOG(WARNING) << "SpillS3FileWriter::~SpillS3FileWriter() failed: " << 
st.to_string()
+                     << ", spill_dir=" << _spill_directory();
+    }
+}
+
+Status SpillS3FileWriter::_wait_for_upload_queue() {
+    auto is_cancelled = [this]() {
+        return _resource_ctx != nullptr && 
_resource_ctx->task_controller()->is_cancelled();
+    };
+    // A cancelled query must not start another (billed) upload.
+    if (is_cancelled()) {
+        return Status::Cancelled("query cancelled before uploading spill 
data");
+    }
+    auto* upload_pool = ExecEnv::GetInstance()->s3_file_upload_thread_pool();

Review Comment:
   这个thread pool 我看是很多任务公用的,为什么这里你可以用它的queue size 来判断 自己spill s3 
是否需要等待呢?会不会直接饿死了?



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