From 836079246322951068f03e9690e78453fc27cc4c Mon Sep 17 00:00:00 2001 From: Sam Ansmink Date: Fri, 22 Dec 2023 15:03:39 +0100 Subject: [PATCH] fix issue with azure http log --- src/azure_extension.cpp | 10 ++++++++-- src/include/azure_extension.hpp | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/azure_extension.cpp b/src/azure_extension.cpp index 5e2056b..df2cda1 100644 --- a/src/azure_extension.cpp +++ b/src/azure_extension.cpp @@ -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 AzureStorageFileSystem::http_state = std::weak_ptr(); bool AzureStorageFileSystem::listener_set = false; @@ -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) { @@ -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) diff --git a/src/include/azure_extension.hpp b/src/include/azure_extension.hpp index ab2c7af..9db01a9 100644 --- a/src/include/azure_extension.hpp +++ b/src/include/azure_extension.hpp @@ -88,6 +88,8 @@ class AzureStorageFileHandle : public FileHandle { class AzureStorageFileSystem : public FileSystem { public: + ~AzureStorageFileSystem(); + duckdb::unique_ptr OpenFile(const string &path, uint8_t flags, FileLockType lock = DEFAULT_LOCK, FileCompressionType compression = DEFAULT_COMPRESSION, FileOpener *opener = nullptr) final;