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 0ccaaf423da [fix](test) Make S3FileWriter boundary test multipart mock
thread-safe (#62149)
0ccaaf423da is described below
commit 0ccaaf423dac57dc644d4ee5898286bfb2f3caa5
Author: Yixuan Wang <[email protected]>
AuthorDate: Thu Apr 9 10:37:49 2026 +0800
[fix](test) Make S3FileWriter boundary test multipart mock thread-safe
(#62149)
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
---
be/test/io/fs/s3_file_writer_test.cpp | 30 +++++++++++++++++++++++++-----
cloud/test/bvars_test.cpp | 4 ++--
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/be/test/io/fs/s3_file_writer_test.cpp
b/be/test/io/fs/s3_file_writer_test.cpp
index d0b8fb18ee7..13f9d12c501 100644
--- a/be/test/io/fs/s3_file_writer_test.cpp
+++ b/be/test/io/fs/s3_file_writer_test.cpp
@@ -1103,6 +1103,7 @@ public:
ObjectStorageUploadResponse create_multipart_upload(
const ObjectStoragePathOptions& opts) override {
+ std::lock_guard lock(_mutex);
create_multipart_count++;
create_multipart_params.push_back(opts);
last_opts = opts;
@@ -1111,6 +1112,7 @@ public:
ObjectStorageResponse put_object(const ObjectStoragePathOptions& opts,
std::string_view stream) override {
+ std::lock_guard lock(_mutex);
put_object_count++;
put_object_params.emplace_back(opts, std::string(stream));
last_opts = opts;
@@ -1122,14 +1124,13 @@ public:
ObjectStorageUploadResponse upload_part(const ObjectStoragePathOptions&
opts,
std::string_view stream, int
part_num) override {
+ std::lock_guard lock(_mutex);
upload_part_count++;
// upload_part_params.push_back({opts, std::string(stream), part_num});
last_opts = opts;
last_stream = std::string(stream);
last_part_num = part_num;
- std::stringstream ss;
- ss << std::setfill('0') << std::setw(3) << part_num;
- parts[opts.path.native() + "_" + ss.str()] = std::string(stream);
+ parts[_part_key(opts.path.native(), part_num)] = std::string(stream);
uploaded_bytes += stream.size();
return default_upload_response;
}
@@ -1137,14 +1138,15 @@ public:
ObjectStorageResponse complete_multipart_upload(
const ObjectStoragePathOptions& opts,
const std::vector<ObjectCompleteMultiPart>& completed_parts)
override {
+ std::lock_guard lock(_mutex);
complete_multipart_count++;
complete_multipart_params.push_back({opts, completed_parts});
last_opts = opts;
last_completed_parts = completed_parts;
std::string final_obj;
final_obj.reserve(uploaded_bytes);
- for (auto& i : parts) {
- final_obj.append(i.second);
+ for (const auto& part : completed_parts) {
+ final_obj.append(parts.at(_part_key(opts.path.native(),
part.part_num)));
}
complete[opts.path.native()] = final_obj;
objects[opts.path.native()] = final_obj;
@@ -1152,6 +1154,7 @@ public:
}
ObjectStorageHeadResponse head_object(const ObjectStoragePathOptions&
opts) override {
+ std::lock_guard lock(_mutex);
return {.resp = ObjectStorageResponse::OK(),
.file_size =
static_cast<int64_t>(objects[opts.path.native()].size())};
}
@@ -1159,6 +1162,7 @@ public:
ObjectStorageResponse get_object(const ObjectStoragePathOptions& opts,
void* buffer,
size_t offset, size_t bytes_read,
size_t* size_return) override {
+ std::lock_guard lock(_mutex);
last_opts = opts;
last_offset = offset;
last_bytes_read = bytes_read;
@@ -1170,6 +1174,7 @@ public:
ObjectStorageResponse list_objects(const ObjectStoragePathOptions& opts,
std::vector<FileInfo>* files) override {
+ std::lock_guard lock(_mutex);
last_opts = opts;
if (files) {
*files = default_file_list;
@@ -1179,24 +1184,28 @@ public:
ObjectStorageResponse delete_objects(const ObjectStoragePathOptions& opts,
std::vector<std::string> objs)
override {
+ std::lock_guard lock(_mutex);
last_opts = opts;
last_deleted_objects = std::move(objs);
return default_response;
}
ObjectStorageResponse delete_object(const ObjectStoragePathOptions& opts)
override {
+ std::lock_guard lock(_mutex);
last_opts = opts;
return default_response;
}
ObjectStorageResponse delete_objects_recursively(
const ObjectStoragePathOptions& opts) override {
+ std::lock_guard lock(_mutex);
last_opts = opts;
return default_response;
}
std::string generate_presigned_url(const ObjectStoragePathOptions& opts,
int64_t expiration_secs, const
S3ClientConf& conf) override {
+ std::lock_guard lock(_mutex);
last_opts = opts;
last_expiration_secs = expiration_secs;
return default_presigned_url;
@@ -1242,6 +1251,7 @@ public:
int64_t uploaded_bytes = 0;
void reset() {
+ std::lock_guard lock(_mutex);
last_opts = ObjectStoragePathOptions {};
last_stream.clear();
last_part_num = 0;
@@ -1263,7 +1273,17 @@ public:
objects.clear();
complete.clear();
parts.clear();
+ uploaded_bytes = 0;
+ }
+
+private:
+ static std::string _part_key(const std::string& path, int part_num) {
+ std::stringstream ss;
+ ss << path << "_" << std::setfill('0') << std::setw(3) << part_num;
+ return ss.str();
}
+
+ std::mutex _mutex;
};
} // namespace io
diff --git a/cloud/test/bvars_test.cpp b/cloud/test/bvars_test.cpp
index 8f895354f18..95062465a4e 100644
--- a/cloud/test/bvars_test.cpp
+++ b/cloud/test/bvars_test.cpp
@@ -69,7 +69,7 @@ TEST(BvarsTest, MultiThreadRecordMetrics) {
MBvarLatencyRecorderWithStatus<60>
mbvarlr_partition_test("partition_test", {"instance_id"});
MBvarLatencyRecorderWithStatus<60> mbvarlr_tablet_test("tablet_test",
{"instance_id"});
- int interval_s = 60;
+ int interval_s = 5;
auto* sp = SyncPoint::get_instance();
sp->set_call_back("mBvarLatencyRecorderWithStatus::put",
[&interval_s](auto&& args) {
auto* vault = try_any_cast<int*>(args[0]);
@@ -121,7 +121,7 @@ TEST(BvarsTest, MultiThreadRecordMetrics) {
t.join();
}
- sleep(interval_s * 3);
+ sleep(interval_s * 2);
ASSERT_GT(update_count.load(), 200);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]