This is an automated email from the ASF dual-hosted git repository.
gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 2a157dc48c1 [fix](storage) Disable BE S3 HTTP redirects by default
(#71223)
2a157dc48c1 is described below
commit 2a157dc48c1016e045043f7f0dc0c6d9711b4ecd
Author: Xin Liao <[email protected]>
AuthorDate: Thu Dec 3 15:54:28 2026 +0800
[fix](storage) Disable BE S3 HTTP redirects by default (#71223)
### Background
S3 table-valued functions pass object storage connection settings to BE.
BE uses the S3 client from the AWS C++ SDK to fetch object data.
### What problem does this PR solve?
Issue Number: None
Related PR: #70443 (shared S3 client implementation)
PR Type: Bugfix
Problem Summary:
The default SDK transport follows HTTP redirects during BE S3 requests.
A storage server can redirect requests to another destination. BE now
disables automatic transport redirects by default. Deployments that rely
on redirects can opt in through a startup setting.
---
be/src/common/config.cpp | 1 +
be/src/common/config.h | 3 +++
.../object_storage/be_obj_storage_config_parser.cpp | 1 +
.../obj_storage_client_factory_test.cpp | 21 +++++++++++++++++++++
common/cpp/obj-storage/client/s3_util.cpp | 5 +++++
.../cpp/obj-storage/parser/obj_storage_config.cpp | 2 +-
common/cpp/obj-storage/parser/obj_storage_config.h | 1 +
7 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index 800db08396a..e55a398db2d 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -1937,6 +1937,7 @@ DEFINE_String(s3_client_http_scheme, "https");
DEFINE_Validator(s3_client_http_scheme, [](const std::string& config) -> bool {
return config == "http" || config == "https";
});
+DEFINE_Bool(s3_client_follow_redirects, "false");
DEFINE_mBool(ignore_schema_change_check, "false");
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 8e3263b9a1e..65518f7ea0e 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -1916,6 +1916,9 @@ DECLARE_mInt32(thrift_client_open_num_tries);
// Default HTTP scheme used by S3Client when the endpoint has no scheme.
DECLARE_String(s3_client_http_scheme);
+// Allow the AWS SDK HTTP transport to automatically follow redirects for BE
S3 clients.
+DECLARE_Bool(s3_client_follow_redirects);
+
DECLARE_mBool(ignore_schema_change_check);
// The min thread num for BufferedReaderPrefetchThreadPool
diff --git a/be/src/io/object_storage/be_obj_storage_config_parser.cpp
b/be/src/io/object_storage/be_obj_storage_config_parser.cpp
index 32c7a27ebe2..8fb645c3d8b 100644
--- a/be/src/io/object_storage/be_obj_storage_config_parser.cpp
+++ b/be/src/io/object_storage/be_obj_storage_config_parser.cpp
@@ -83,6 +83,7 @@ void apply_be_obj_storage_defaults(ObjStorageClientConfig&
client) {
if constexpr (std::is_same_v<C, AzureObjStorageConfig>) {
settings.retry_too_many_requests = true;
} else {
+ settings.connection.follow_redirects =
config::s3_client_follow_redirects;
if (!settings.connection.max_connections) {
settings.connection.max_connections = 102400;
}
diff --git a/be/test/io/object_storage/obj_storage_client_factory_test.cpp
b/be/test/io/object_storage/obj_storage_client_factory_test.cpp
index 07a70302ced..27b4fdb4aa4 100644
--- a/be/test/io/object_storage/obj_storage_client_factory_test.cpp
+++ b/be/test/io/object_storage/obj_storage_client_factory_test.cpp
@@ -1246,6 +1246,27 @@ TEST_F(S3ClientFactoryTest,
EffectiveAwsEndpointControlsSdkScheme) {
}
}
+TEST_F(S3ClientFactoryTest, BeS3HttpRedirectPolicy) {
+ const Properties properties {{"AWS_ENDPOINT", "https://s3.example.com"},
+ {"AWS_REGION", "us-east-1"}};
+ auto by_default = parse_be_obj_storage_config(properties, "bucket");
+ const bool saved = std::exchange(config::s3_client_follow_redirects, true);
+ auto opted_in = parse_be_obj_storage_config(properties, "bucket");
+ config::s3_client_follow_redirects = saved;
+
+ EXPECT_FALSE(saved);
+ ASSERT_TRUE(by_default.has_value());
+ ASSERT_TRUE(opted_in.has_value());
+ const auto& defaults =
std::get<AwsObjStorageConfig>(by_default.value().client);
+ const auto& enabled =
std::get<AwsObjStorageConfig>(opted_in.value().client);
+ EXPECT_EQ(make_s3_sdk_config(defaults.connection, defaults.region,
defaults.retry_slow_down)
+ .followRedirects,
+ Aws::Client::FollowRedirectsPolicy::NEVER);
+ EXPECT_EQ(make_s3_sdk_config(enabled.connection, enabled.region,
enabled.retry_slow_down)
+ .followRedirects,
+ Aws::Client::FollowRedirectsPolicy::DEFAULT);
+}
+
TEST_F(S3ClientFactoryTest, ConvertPropertiesToS3ConfRoleArnProviderType) {
std::map<std::string, std::string> properties {
{"AWS_ENDPOINT", "s3.us-west-2.amazonaws.com"},
diff --git a/common/cpp/obj-storage/client/s3_util.cpp
b/common/cpp/obj-storage/client/s3_util.cpp
index e36cbd021e7..e66a3c41888 100644
--- a/common/cpp/obj-storage/client/s3_util.cpp
+++ b/common/cpp/obj-storage/client/s3_util.cpp
@@ -41,6 +41,11 @@ Aws::Client::ClientConfiguration make_s3_sdk_config(const
ObjStorageConnectionCo
const bool http =
automatic_endpoint ? automatic_http :
connection.endpoint.starts_with("http://");
options.scheme = http ? Aws::Http::Scheme::HTTP : Aws::Http::Scheme::HTTPS;
+ // Disable transport redirects from SQL-selected endpoints. The SDK
default preserves
+ // the special handling for aws-global when the operator opts back in.
+ options.followRedirects = connection.follow_redirects
+ ?
Aws::Client::FollowRedirectsPolicy::DEFAULT
+ :
Aws::Client::FollowRedirectsPolicy::NEVER;
if (connection.ca_cert_file) {
options.caFile = *connection.ca_cert_file;
}
diff --git a/common/cpp/obj-storage/parser/obj_storage_config.cpp
b/common/cpp/obj-storage/parser/obj_storage_config.cpp
index dfc47867b7e..d9674f7716d 100644
--- a/common/cpp/obj-storage/parser/obj_storage_config.cpp
+++ b/common/cpp/obj-storage/parser/obj_storage_config.cpp
@@ -311,7 +311,7 @@ size_t ObjStorageClientHash::operator()(const
ObjStorageClientConfig& config) co
size_t seed =
fields(client.provider, conn.endpoint,
conn.ca_cert_file,
conn.max_connections, conn.connect_timeout,
conn.request_timeout,
- conn.max_retries, auth_hash(client.auth));
+ conn.max_retries, conn.follow_redirects,
auth_hash(client.auth));
if constexpr (std::is_same_v<C, AzureObjStorageConfig>) {
combine(seed, client.retry_too_many_requests);
} else {
diff --git a/common/cpp/obj-storage/parser/obj_storage_config.h
b/common/cpp/obj-storage/parser/obj_storage_config.h
index 3cc0f9636ca..60c4baa8374 100644
--- a/common/cpp/obj-storage/parser/obj_storage_config.h
+++ b/common/cpp/obj-storage/parser/obj_storage_config.h
@@ -35,6 +35,7 @@ struct ObjStorageConnectionConfig {
std::optional<std::chrono::milliseconds> connect_timeout {};
std::optional<std::chrono::milliseconds> request_timeout {};
std::optional<int> max_retries {};
+ bool follow_redirects = true;
bool operator==(const ObjStorageConnectionConfig&) const = default;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]