Skip to content

Commit c538452

Browse files
committed
fix
1 parent dfd1e78 commit c538452

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

src/paimon/common/fs/file_system_test.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ TEST_P(FileSystemTest, TestMkdir2) {
10171017
}
10181018
}
10191019

1020-
// test for create multi dir such as "partition1/bucket1" and "partition1/bucket2"
1020+
// test for create multi dir such as "/table/partition1/bucket1" and "/table/partition1/bucket2"
10211021
TEST_P(FileSystemTest, TestMkdirMultiThread) {
10221022
uint32_t runs_count = 10;
10231023
uint32_t thread_count = 10;
@@ -1042,7 +1042,7 @@ TEST_P(FileSystemTest, TestMkdirMultiThread) {
10421042
}
10431043
}
10441044

1045-
// test for create multi dir such as "partition1" and "partition1"
1045+
// test for create multi dir such as "/table/partition1" and "/table/partition1"
10461046
TEST_P(FileSystemTest, TestMkdirMultiThread2) {
10471047
uint32_t runs_count = 10;
10481048
uint32_t thread_count = 10;
@@ -1055,8 +1055,28 @@ TEST_P(FileSystemTest, TestMkdirMultiThread2) {
10551055
for (uint32_t thread_idx = 0; thread_idx < thread_count; thread_idx++) {
10561056
futures.push_back(Via(executor.get(), [this, &uuid]() -> void {
10571057
std::string dir_path = PathUtil::JoinPath(test_root_, uuid);
1058-
// ASSERT_OK_AND_ASSIGN(bool is_exist, fs_->Exists(dir_path));
1059-
// ASSERT_FALSE(is_exist);
1058+
ASSERT_OK(fs_->Mkdirs(dir_path));
1059+
ASSERT_OK_AND_ASSIGN(bool is_exist, fs_->Exists(dir_path));
1060+
ASSERT_TRUE(is_exist);
1061+
}));
1062+
}
1063+
Wait(futures);
1064+
}
1065+
}
1066+
1067+
// test for create multi dir such as "partition1" and "partition1" (relative path)
1068+
TEST_P(FileSystemTest, TestMkdirMultiThread3) {
1069+
uint32_t runs_count = 10;
1070+
uint32_t thread_count = 10;
1071+
auto executor = CreateDefaultExecutor(thread_count);
1072+
1073+
for (uint32_t i = 0; i < runs_count; i++) {
1074+
std::string uuid;
1075+
ASSERT_TRUE(UUID::Generate(&uuid));
1076+
std::vector<std::future<void>> futures;
1077+
for (uint32_t thread_idx = 0; thread_idx < thread_count; thread_idx++) {
1078+
futures.push_back(Via(executor.get(), [this, &uuid]() -> void {
1079+
std::string dir_path = uuid;
10601080
ASSERT_OK(fs_->Mkdirs(dir_path));
10611081
ASSERT_OK_AND_ASSIGN(bool is_exist, fs_->Exists(dir_path));
10621082
ASSERT_TRUE(is_exist);

src/paimon/fs/local/local_file.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,19 @@ Status LocalFile::Mkdir() const {
158158
size_t len = dir.size();
159159
if (dir[len - 1] == '/') {
160160
if (len == 1) {
161-
return Status::Exist(fmt::format("directory '{}' already exist", dir));
161+
return Status::OK();
162162
} else {
163163
dir.resize(len - 1);
164164
}
165165
}
166166
size_t pos = dir.rfind('/');
167167
if (pos == std::string::npos) {
168168
if (mkdir(dir.c_str(), 0755) < 0) {
169-
int32_t cur_errno = errno;
170-
return Status::IOError(
171-
fmt::format("Mkdir path '{}' fail, ec: {}", dir, std::strerror(cur_errno)));
169+
if (errno != EEXIST) {
170+
int32_t cur_errno = errno;
171+
return Status::IOError(
172+
fmt::format("Mkdir path '{}' fail, ec: {}", dir, std::strerror(cur_errno)));
173+
}
172174
}
173175
return Status::OK();
174176
}

src/paimon/fs/local/local_file_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ TEST(LocalFileTest, TestOpenFile) {
178178
ASSERT_GE(modify_time, -1);
179179

180180
LocalFile dir2 = LocalFile("/");
181-
ASSERT_NOK_WITH_MSG(dir2.Mkdir(), "directory '/' already exist");
181+
ASSERT_OK(dir2.Mkdir());
182182
LocalFile dir3 = LocalFile(test_root + "/");
183-
ASSERT_NOK_WITH_MSG(dir3.Mkdir(), "already exist");
183+
ASSERT_OK(dir3.Mkdir());
184184
}
185185

186186
} // namespace paimon::test

0 commit comments

Comments
 (0)