pitrou commented on code in PR #40110:
URL: https://github.com/apache/arrow/pull/40110#discussion_r1497298696
##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -3004,6 +3004,8 @@ Status InitializeS3(const S3GlobalOptions& options) {
}
Status EnsureS3Initialized() {
+ static std::mutex init_mutex;
+ std::lock_guard<std::mutex> l(init_mutex);
Review Comment:
Why not put this in `AwsInstance`?
##########
cpp/src/arrow/filesystem/s3fs_test.cc:
##########
@@ -1272,6 +1272,30 @@ TEST_F(TestS3FS, FileSystemFromUri) {
AssertFileInfo(fs.get(), path, FileType::File, 8);
}
+TEST_F(TestS3FS, ConcurrentFSInit) {
+ auto test_thread = [this]() {
+ std::stringstream ss;
+ ss << "s3://" << minio_->access_key() << ":" << minio_->secret_key()
+ << "@bucket/somedir/subdir/subfile"
+ << "?scheme=http&endpoint_override=" <<
UriEscape(minio_->connect_string());
+
+ std::string path;
+ ASSERT_OK(FileSystemFromUri(ss.str(), &path));
+ };
+
+ const int num_threads = 4;
+ auto threads = std::vector<std::thread>();
+ for (int i = 0; i < num_threads; i++) {
+ threads.emplace_back(test_thread);
+ }
+
+ for (auto& thread : threads) {
+ thread.join();
+ }
+
+ static_cast<void>(FinalizeS3());
Review Comment:
This may break subsequent tests?
##########
cpp/src/arrow/filesystem/s3fs_test.cc:
##########
@@ -1272,6 +1272,30 @@ TEST_F(TestS3FS, FileSystemFromUri) {
AssertFileInfo(fs.get(), path, FileType::File, 8);
}
+TEST_F(TestS3FS, ConcurrentFSInit) {
Review Comment:
Individual tests are not executed in separate process. The S3 subsystem is
probably already initialized by the time this test is executed.
You could instead turn this into a Python test, where it's easier to spawn a
subprocess.
##########
cpp/src/arrow/filesystem/s3fs_test.cc:
##########
@@ -1272,6 +1272,30 @@ TEST_F(TestS3FS, FileSystemFromUri) {
AssertFileInfo(fs.get(), path, FileType::File, 8);
}
+TEST_F(TestS3FS, ConcurrentFSInit) {
Review Comment:
Individual tests are not executed in a separate process. The S3 subsystem is
probably already initialized by the time this test is executed.
You could instead turn this into a Python test, where it's easier to spawn a
subprocess.
--
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]