Skip to content

Commit

Permalink
fix issue with azure http log
Browse files Browse the repository at this point in the history
  • Loading branch information
samansmink committed Dec 22, 2023
1 parent e0a5402 commit 8360792
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/azure_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace duckdb {

using namespace Azure::Core::Diagnostics;

// globals for collection Azure SDK logging information
mutex AzureStorageFileSystem::azure_log_lock = {};
weak_ptr<HTTPState> AzureStorageFileSystem::http_state = std::weak_ptr<HTTPState>();
bool AzureStorageFileSystem::listener_set = false;
Expand All @@ -38,7 +39,7 @@ bool AzureStorageFileSystem::listener_set = false;
static void Log(Logger::Level level, std::string const &message) {
auto http_state_ptr = AzureStorageFileSystem::http_state;
auto http_state = http_state_ptr.lock();
if (!http_state) {
if (!http_state && AzureStorageFileSystem::listener_set) {
throw std::runtime_error("HTTP state weak pointer failed to lock");
}
if (message.find("Request") != std::string::npos) {
Expand Down Expand Up @@ -215,7 +216,12 @@ BlobClientWrapper::BlobClientWrapper(AzureAuthentication &auth, AzureParsedUrl &
BlobClientWrapper::~BlobClientWrapper() = default;
Azure::Storage::Blobs::BlobClient *BlobClientWrapper::GetClient() {
return blob_client.get();
};
}

AzureStorageFileSystem::~AzureStorageFileSystem() {
Logger::SetListener(nullptr);
AzureStorageFileSystem::listener_set = false;
}

AzureStorageFileHandle::AzureStorageFileHandle(FileSystem &fs, string path_p, uint8_t flags, AzureAuthentication &auth,
const AzureReadOptions &read_options, AzureParsedUrl parsed_url)
Expand Down
2 changes: 2 additions & 0 deletions src/include/azure_extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class AzureStorageFileHandle : public FileHandle {

class AzureStorageFileSystem : public FileSystem {
public:
~AzureStorageFileSystem();

duckdb::unique_ptr<FileHandle> OpenFile(const string &path, uint8_t flags, FileLockType lock = DEFAULT_LOCK,
FileCompressionType compression = DEFAULT_COMPRESSION,
FileOpener *opener = nullptr) final;
Expand Down

0 comments on commit 8360792

Please sign in to comment.