This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new 659dcc79453 branch-4.2: [fix](cloud) Add configurable GCS object
deletion #70119 (#70323)
659dcc79453 is described below
commit 659dcc79453452ab5c9a8573d0283e3538e5f42f
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Nov 24 15:33:59 2026 +0800
branch-4.2: [fix](cloud) Add configurable GCS object deletion #70119
(#70323)
Cherry-picked from #70119
Co-authored-by: Yixuan Wang <[email protected]>
---
cloud/src/common/config.h | 2 +
cloud/src/recycler/s3_accessor.cpp | 88 +++++++++++++++++++++++++++++++++++++-
cloud/src/recycler/s3_accessor.h | 11 +++++
3 files changed, 100 insertions(+), 1 deletion(-)
diff --git a/cloud/src/common/config.h b/cloud/src/common/config.h
index f851b4303d3..1fb02f9afa3 100644
--- a/cloud/src/common/config.h
+++ b/cloud/src/common/config.h
@@ -322,6 +322,8 @@ CONF_String(priority_networks, "");
CONF_Bool(enable_cluster_name_check, "false");
+CONF_Bool(enable_gcs_batch_delete_object, "true");
+
// Default HTTP scheme used by S3Client when the endpoint has no scheme.
CONF_String(s3_client_http_scheme, "https");
CONF_Validator(s3_client_http_scheme, [](const std::string& config) -> bool {
diff --git a/cloud/src/recycler/s3_accessor.cpp
b/cloud/src/recycler/s3_accessor.cpp
index bebb72c609d..50eb70dd844 100644
--- a/cloud/src/recycler/s3_accessor.cpp
+++ b/cloud/src/recycler/s3_accessor.cpp
@@ -337,7 +337,17 @@ std::string S3Accessor::to_uri(const std::string&
relative_path) const {
int S3Accessor::create(S3Conf conf, std::shared_ptr<S3Accessor>* accessor) {
TEST_SYNC_POINT_RETURN_WITH_VALUE("S3Accessor::init.s3_init_failed",
(int)-1);
- *accessor = std::make_shared<S3Accessor>(conf);
+ switch (conf.provider) {
+ case S3Conf::GCS:
+ if (!config::enable_gcs_batch_delete_object) {
+ *accessor = std::make_shared<GcsAccessor>(conf);
+ break;
+ }
+ default:
+ *accessor = std::make_shared<S3Accessor>(conf);
+ break;
+ }
+
return (*accessor)->init();
}
@@ -621,4 +631,80 @@ int S3Accessor::check_versioning() {
return obj_client_->check_versioning(conf_.bucket).status.code;
}
+int GcsAccessor::delete_prefix_impl(const std::string& path_prefix, int64_t
expiration_time) {
+ LOG_INFO("begin delete prefix").tag("uri", to_uri(path_prefix));
+
+ int ret = 0;
+ int cnt = 0;
+ int skip = 0;
+ int64_t del_nonexisted = 0;
+ int del = 0;
+ auto iter = obj_client_->list_objects({.bucket = conf_.bucket, .prefix =
get_key(path_prefix)});
+ for (;;) {
+ auto result = iter->next();
+ if (!result.object.has_value()) {
+ if (result.resp.status.code != ObjStorageStatus::NOT_FOUND &&
+ result.resp.status.code != ObjStorageStatus::OK) {
+ ret = result.resp.status.code;
+ }
+ break;
+ }
+ auto& obj = *result.object;
+ if (!(++cnt % 100)) {
+ LOG_INFO("loop delete prefix")
+ .tag("uri", to_uri(path_prefix))
+ .tag("total_obj_cnt", cnt)
+ .tag("deleted", del)
+ .tag("del_nonexisted", del_nonexisted)
+ .tag("skipped", skip);
+ }
+ if (expiration_time > 0 && obj.mtime_s > expiration_time) {
+ skip++;
+ continue;
+ }
+ del++;
+
+ // FIXME(plat1ko): Delete objects by batch with genuine GCS client
+ int del_ret =
+ obj_client_->delete_object({.bucket = conf_.bucket, .key =
obj.key}).status.code;
+ del_nonexisted += (del_ret == ObjStorageStatus::NOT_FOUND);
+ static_assert(ObjStorageStatus::OK == 0);
+ if (del_ret != ObjStorageStatus::OK && del_ret !=
ObjStorageStatus::NOT_FOUND) {
+ ret = del_ret;
+ }
+ }
+
+ LOG_INFO("finish delete prefix")
+ .tag("uri", to_uri(path_prefix))
+ .tag("total_obj_cnt", cnt)
+ .tag("deleted", del)
+ .tag("del_nonexisted", del_nonexisted)
+ .tag("skipped", skip);
+
+ if (!iter->is_valid()) {
+ return -1;
+ }
+
+ return ret;
+}
+
+int GcsAccessor::delete_files(const std::vector<std::string>& paths) {
+ std::vector<int> delete_rets(paths.size());
+#ifdef USE_LIBCPP
+ std::transform(paths.begin(), paths.end(), delete_rets.begin(),
+#else
+ std::transform(std::execution::par, paths.begin(), paths.end(),
delete_rets.begin(),
+#endif
+ [this](const std::string& path) { return delete_file(path);
});
+
+ int ret = 0;
+ for (int delete_ret : delete_rets) {
+ if (delete_ret != 0) {
+ ret = delete_ret;
+ break;
+ }
+ }
+ return ret;
+}
+
} // namespace doris::cloud
diff --git a/cloud/src/recycler/s3_accessor.h b/cloud/src/recycler/s3_accessor.h
index 5a0b48628a0..adee55e2195 100644
--- a/cloud/src/recycler/s3_accessor.h
+++ b/cloud/src/recycler/s3_accessor.h
@@ -160,5 +160,16 @@ protected:
std::string _ca_cert_file_path;
};
+class GcsAccessor final : public S3Accessor {
+public:
+ explicit GcsAccessor(S3Conf conf) : S3Accessor(std::move(conf)) {}
+ ~GcsAccessor() override = default;
+
+ int delete_files(const std::vector<std::string>& paths) override;
+
+private:
+ int delete_prefix_impl(const std::string& path_prefix, int64_t
expiration_time = 0) override;
+};
+
} // namespace cloud
} // namespace doris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]