Skip to content

Commit

Permalink
Add comments and debug check
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Feb 26, 2024
1 parent 075c998 commit ce9e256
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2899,9 +2899,12 @@ struct AwsInstance {
return Status::Invalid("Attempt to initialize S3 after it has been finalized");
}
bool newly_initialized = false;
// EnsureInitialized() can be called concurrently by FileSystemFromUri,
// therefore we need to serialize initialization (GH-39897).
std::call_once(initialize_flag_, [&]() {
bool was_initialized = is_initialized_.exchange(true);
DCHECK(!was_initialized);
DoInitialize(options);
is_initialized_.exchange(true);
newly_initialized = true;
});
return newly_initialized;
Expand Down
3 changes: 2 additions & 1 deletion python/pyarrow/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,8 @@ def test_s3_finalize_region_resolver():


@pytest.mark.s3
def test_concurrent_fs_init():
def test_concurrent_s3fs_init():
# GH-39897: lazy concurrent initialization of S3 subsystem should not crash
code = """if 1:
import threading
import pytest
Expand Down

0 comments on commit ce9e256

Please sign in to comment.