From dd7e88b37eb33ad962b108edc87da493cf24b142 Mon Sep 17 00:00:00 2001 From: Julia Kartseva Date: Thu, 2 May 2024 05:52:11 +0000 Subject: [PATCH] fix infinite loop in AzureObjectStorage::listObjects While the exit condition is correct for `AzureIteratorAsync`, listObject may never exit. This is because BlobContainerClient::LstBlobs sets a page, thus making a sequential HasPage() condition true. This issue reproduces when passing an empty path. Tested with the following integration test: https://pastila.nl/?01691b54/9ceaf103c91ab9e38ea3541abfcd1ae6#hUtrrz5sFHcBSHCLS9AlVA== (will be added when plain_rewritable is enabled for all disk types). --- .../AzureBlobStorage/AzureObjectStorage.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Disks/ObjectStorages/AzureBlobStorage/AzureObjectStorage.cpp b/src/Disks/ObjectStorages/AzureBlobStorage/AzureObjectStorage.cpp index 0f45f40288e..4c5cd57615b 100644 --- a/src/Disks/ObjectStorages/AzureBlobStorage/AzureObjectStorage.cpp +++ b/src/Disks/ObjectStorages/AzureBlobStorage/AzureObjectStorage.cpp @@ -164,15 +164,13 @@ void AzureObjectStorage::listObjects(const std::string & path, RelativePathsWith else options.PageSizeHint = settings.get()->list_object_keys_size; - Azure::Storage::Blobs::ListBlobsPagedResponse blob_list_response; - - while (true) + for (auto blob_list_response = client_ptr->ListBlobs(options); blob_list_response.HasPage(); blob_list_response.MoveToNextPage()) { ProfileEvents::increment(ProfileEvents::AzureListObjects); ProfileEvents::increment(ProfileEvents::DiskAzureListObjects); blob_list_response = client_ptr->ListBlobs(options); - auto blobs_list = blob_list_response.Blobs; + const auto & blobs_list = blob_list_response.Blobs; for (const auto & blob : blobs_list) { @@ -193,11 +191,6 @@ void AzureObjectStorage::listObjects(const std::string & path, RelativePathsWith break; options.PageSizeHint = keys_left; } - - if (blob_list_response.HasPage()) - options.ContinuationToken = blob_list_response.NextPageToken; - else - break; } }