mrhhsg commented on code in PR #68032: URL: https://github.com/apache/doris/pull/68032#discussion_r4119383166
########## be/src/exec/spill/remote_spill_data_dir.cpp: ########## @@ -0,0 +1,133 @@ +// 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/remote_spill_data_dir.h" + +#include <glog/logging.h> + +#include <utility> + +#include "cloud/cloud_storage_engine.h" +#include "cloud/config.h" +#include "common/config.h" +#include "common/logging.h" +#include "common/metrics/metrics.h" +#include "io/fs/remote_file_system.h" +#include "runtime/exec_env.h" +#include "service/backend_options.h" +#include "storage/olap_define.h" +#include "storage/storage_policy.h" +#include "util/pretty_printer.h" + +namespace doris { + +RemoteSpillDataDir::RemoteSpillDataDir(std::string vault_id) + : SpillDataDir(fmt::format("s3:{}", vault_id.empty() ? "default" : vault_id), + /*spill_root=*/"", + fmt::format("s3:{}", vault_id.empty() ? "default" : vault_id), + /*capacity_bytes=*/0, TStorageMedium::S3), + _vault_id(std::move(vault_id)) {} + +Status RemoteSpillDataDir::init() { + RETURN_IF_ERROR(update_capacity()); + LOG(INFO) << fmt::format("remote spill store registered, vault_id={}, limit={}", + _vault_id.empty() ? "<default>" : _vault_id, + PrettyPrinter::print_bytes(_spill_data_limit_bytes)); + return Status::OK(); +} + +Status RemoteSpillDataDir::ensure_ready() { + if (ready()) { + return Status::OK(); + } + std::lock_guard<std::mutex> lock(_init_mutex); + if (ready()) { + return Status::OK(); + } + if (!config::is_cloud_mode()) { + return Status::InternalError("spill to s3 is only supported in cloud mode"); + } + const std::string& host = BackendOptions::get_localhost(); + if (host.empty()) { + return Status::InternalError("spill to s3 is not ready: the address of this BE is unknown"); + } + std::string endpoint = fmt::format("{}_{}", host, config::heartbeat_service_port); Review Comment: The only consumer that deleted by prefix (the startup cleanup) was removed in 422b839. Keys below the root are `{query_id}/...` with a random 128-bit query id, and each BE deletes only the prefix of its own SpillFile, so two instances sharing a vault and an endpoint cannot delete each other's data. ########## cloud/src/recycler/recycler.cpp: ########## @@ -1000,6 +1003,14 @@ int InstanceRecycler::recycle_deleted_instance_data() { instance_info().snapshot_switch_status() != SnapshotSwitchStatus::SNAPSHOT_SWITCH_DISABLED; if (snapshot_enabled) { + // Only referenced rowsets are recycled selectively below because the vault may be + // shared with other instances. Spill objects (spill/{ip}_{port}/...) do not say which + // instance wrote them, so only the expired ones are removed, as for a live instance. + if (recycle_expired_spill_objects() != 0) { Review Comment: Obsolete: the recycler spill sweep was removed in 422b839 (`cloud/` is identical to master). ########## be/src/exec/operator/spill_counters.h: ########## @@ -33,6 +33,11 @@ struct SpillWriteCounters { RuntimeProfile::Counter* spill_write_block_count = nullptr; RuntimeProfile::Counter* spill_write_block_data_size = nullptr; RuntimeProfile::Counter* spill_write_rows_count = nullptr; + RuntimeProfile::Counter* spill_remote_write_requests = nullptr; Review Comment: Fixed in bdd4fad: `SpillIcebergTableSinkLocalState::_init_spill_counters()` registers the remote write and read counters. -- 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]
