Skip to content

Fix ObjectStorageQueue/AzureQueue silently skipping files on an empty listing page with a continuation token - #109761

Merged
kssenii merged 1 commit into
ClickHouse:masterfrom
GalBenMoshe:fix-objectstorage-iterator-empty-page
Jul 10, 2026
Merged

kssenii merged 1 commit into
ClickHouse:masterfrom
GalBenMoshe:fix-objectstorage-iterator-empty-page

Conversation

@GalBenMoshe

@GalBenMoshe GalBenMoshe commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix ObjectStorageQueue/AzureQueue (and the azureBlobStorage table function) silently skipping objects when the object storage returns an empty listing page together with a continuation token. Azure Blob Storage does this (e.g. when a listing crosses an internal partition boundary), and the async list iterator was treating the empty page as the end of the listing and dropping the token. It now follows the continuation token.

Description

Closes #109751.

IObjectStorageIteratorAsync::nextBatch() treated an empty listing page as end-of-listing: on current_batch.empty() it set is_finished = true / has_next_batch = false and never read result.has_next, so it discarded the continuation token and never fetched later pages.

Azure Blob Storage's List Blobs may legitimately return a page with zero results but a non-empty NextMarker — the client must keep following the marker until it is empty. This is documented behavior and happens, for example, when a listing crosses an internal partition boundary in a large container. Because ClickHouse stopped on the first empty page, AzureQueue and azureBlobStorage(...) silently returned fewer/zero objects than actually exist: the queue "lists forever but processes nothing" (AzureListObjects keeps climbing while ObjectStorageQueueListedFiles / ObjectStorageQueueProcessedFiles stay at 0). It is intermittent because it depends on Azure's partition layout, and can self-recover when the layout changes.

S3/GCS are unaffected: their iterator returns has_next = IsTruncated, and ListObjectsV2 does not return an empty page with IsTruncated=true for a prefix that has matching keys, so the empty branch was only reached at true end-of-listing.

Azure docs confirming the empty-page-with-marker behavior:

Fix: in nextBatch(), honor has_next regardless of whether the page is empty — keep following the continuation token, and only finish when a page is empty and there are no more pages.

Test: added src/Disks/DiskObjectStorage/ObjectStorages/tests/gtest_object_storage_iterator_async.cpp — a scripted iterator that returns an empty page + "has more" followed by real pages (and an empty intermediate page), asserting all objects are returned. With the previous behavior it returns nothing; with the fix it returns all objects.

Version info

  • Merged into: 26.7.1.747 (included in 26.7 and later)
  • Backported to: 26.6.5.68, 26.3.33.11

@CLAassistant

CLAassistant commented Jul 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Jul 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a45833f]

Summary: ✅


AI Review

Summary

This PR fixes IObjectStorageIteratorAsync::nextBatch() so Azure-style empty listing pages with a continuation token no longer terminate iteration early, and adds focused regression coverage for both batch-wise and element-wise consumers. The current implementation matches that contract, the prior iterator-validity concern has been addressed in the latest code, and I did not find any remaining correctness issues in the changed paths.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 8, 2026
@kssenii kssenii self-assigned this Jul 8, 2026
@GalBenMoshe
GalBenMoshe force-pushed the fix-objectstorage-iterator-empty-page branch from 28df446 to 6d30e28 Compare July 8, 2026 18:23
@GalBenMoshe
GalBenMoshe force-pushed the fix-objectstorage-iterator-empty-page branch from 6d30e28 to 59e6e66 Compare July 9, 2026 11:29
…e with continuation token

IObjectStorageIteratorAsync::nextBatch() treated an empty listing page as
end-of-listing and dropped the continuation token. Azure Blob Storage can
return an empty page with a non-empty NextMarker (e.g. at a partition
boundary), so AzureQueue / azureBlobStorage silently skipped objects on
later pages. Follow the token instead: only finish when a page is empty AND
there are no more pages. Adds a unit test.

Closes ClickHouse#109751.
@GalBenMoshe
GalBenMoshe force-pushed the fix-objectstorage-iterator-empty-page branch from 59e6e66 to a45833f Compare July 9, 2026 13:16
@clickhouse-gh

clickhouse-gh Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.80% 85.80% +0.00%
Functions 92.70% 92.70% +0.00%
Branches 77.90% 78.00% +0.10%

Changed lines: Changed C/C++ lines covered: 54/55 (98.18%) · Uncovered code

Full report · Diff report

@kssenii
kssenii added this pull request to the merge queue Jul 10, 2026
Merged via the queue into ClickHouse:master with commit 8a042fd Jul 10, 2026
175 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 10, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

TL;DR

Fix ObjectStorageQueue/AzureQueue silently skipping files on an empty listing page with a continuation token

ClickGap verified: reproduced it with the script below on 26.6; tested 7 version(s) — 6 affected, 1 clean (see Affects).

Reproduction

No SQL repro exists: the bug fires only when the object-storage backend returns an empty listing page together with a non-empty continuation token (Azure Blob Storage List Blobs at an internal partition boundary), which cannot be produced deterministically from a clickhouse invocation. Operational symptom on an affected build: an AzureQueue / ObjectStorageQueue over a large Azure container (or azureBlobStorage(...) table function) returns fewer/zero objects than exist — the queue 'lists forever but processes nothing' (metric AzureListObjects keeps climbing while ObjectStorageQueueListedFiles / ObjectStorageQueueProcessedFiles stay at 0). Deterministically covered by the C++ unit test ObjectStorageIteratorAsync.EmptyPageWithContinuationTokenDoesNotStopListing (src/Disks/DiskObjectStorage/ObjectStorages/tests/gtest_object_storage_iterator_async.cpp): pre-fix returns nothing, post-fix returns all objects.

Bisect

⚠ affects matrix shows regression boundary but bisect did not converge — introducing PR is unverified

  • Bisect not performed — master is already clean (the fix landed there), so there is no caused-by regression boundary to bisect within the supported releases.

Affects

  • ✓ Fix is on master — this PR's change fixes the bug on master. Branches below still have the bug and need the backport.
  • Reproduces on: 26.6, 26.5, 26.4, 26.3, 26.2, 26.1
  • Does NOT reproduce on: master
  • Backport needed: 26.6, 26.5, 26.4, 26.3, 26.2, 26.1

Suggested next step

The fix has landed on master; the affected release branches above still need the backport.

Component: comp-object-storage-disks
Severity: P2

cc fix PR author: @GalBenMoshe
cc fix PR reviewer: @kssenii


ClickGap · Finding: phase_d_pr109761

Triage metadata

  • Primary component: comp-object-storage-disks
  • Secondary components: comp-testing
  • Component owners (comp-object-storage-disks): @Michicosun @kssenii

@CheSema

CheSema commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

This is a severe bug. We need to backport it as far back as we can.

Rewritable disk does full listing at the start to collect all the directories in it. If we get not full listing here, all the tables on this disk would be corrupted.

@kssenii kssenii added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 7, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 7, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 7, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 7, 2026
Backport #109761 to 26.6: Fix ObjectStorageQueue/AzureQueue silently skipping files on an empty listing page with a continuation token
CheSema added a commit that referenced this pull request Sep 8, 2026
Backport #109761 to 26.3: Fix ObjectStorageQueue/AzureQueue silently skipping files on an empty listing page with a continuation token
CheSema added a commit that referenced this pull request Sep 8, 2026
Picks up the backport of #109761, without which the plain_rewritable per-directory
file listing still stops on an empty page and the new integration test fails.
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 11, 2026
… silently skipping files on an empty listing page with a continuation token
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 11, 2026
… silently skipping files on an empty listing page with a continuation token
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ge-iterator-empty-page

Fix ObjectStorageQueue/AzureQueue silently skipping files on an empty listing page with a continuation token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ObjectStorageQueue with AzureQueue engine can silently skip files that exist in Azure Blob Storage

8 participants