Skip to content

Support azure datalake storage gen2 writer - #105406

Merged
scanhex12 merged 21 commits into
ClickHouse:masterfrom
scanhex12:adlfs_gen2
Jun 9, 2026
Merged

scanhex12 merged 21 commits into
ClickHouse:masterfrom
scanhex12:adlfs_gen2

Conversation

@scanhex12

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

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

Support writing into such storage https://learn.microsoft.com/en-us/training/modules/introduction-to-azure-data-lake-storage/2-azure-data-lake-gen2

@scanhex12
scanhex12 marked this pull request as draft May 20, 2026 11:05
@clickhouse-gh

clickhouse-gh Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [52d8c3f]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/feature_docs.py FAIL

AI Review

Summary

This PR adds an ADLS/OneLake write/delete path for Azure object storage by routing selected Fabric endpoints through WriteBufferFromAzureDataLakeStorage. I do not think it is ready to merge yet: the new writer still bypasses existing Azure write durability/accounting controls, has an unsafe rollback path for existing-object rewrites, and does not have a focused test covering the new branch.

PR Metadata
  • Changelog category: New Feature is reasonable if this is intended as a new writer capability.
  • Changelog entry: required and present, but too vague. It says "such storage" and relies on an external link instead of naming the user-visible feature. If the scope remains Fabric/OneLake-only, replace it with: Add write support for Microsoft OneLake/Fabric-backed Azure object storage. If the intended scope is generic ADLS Gen2, the endpoint detection needs to support standard ADLS Gen2 endpoints too.
Findings

❌ Blockers

  • [src/Disks/IO/WriteBufferFromAzureDataLakeStorage.cpp:287] [dismissed by author -- https://github.com/Support azure datalake storage gen2 writer #105406#discussion_r3337260121] cancelImpl deletes the final path whenever Create succeeded and finalize did not complete. That is only safe for known-new objects. Current Iceberg code rewrites metadata/version-hint.text with object_storage_write_if_match; if Create truncates/replaces the matched existing file and then Append or Flush fails, cancelImpl deletes the previously existing hint instead of preserving it. Please write to a temporary ADLS path and atomically/conditionally commit it, or reject object_storage_write_if_match and existing-target rewrites until old contents can be preserved.

⚠️ Majors

  • [src/Disks/IO/WriteBufferFromAzureDataLakeStorage.cpp:277] WriteBufferFromAzureDataLakeStorage still ignores RequestSettings::check_objects_after_upload. Users who enabled azure_check_objects_after_upload lose the post-upload visibility check only on the ADLS branch. Please carry the setting into this writer and verify the object after Flush, matching WriteBufferFromAzureBlobStorage.
  • [src/Disks/IO/WriteBufferFromAzureDataLakeStorage.cpp:225] The ADLS Append path bypasses write_settings.remote_throttler, while S3 and Azure Blob writers account uploaded bytes before sending them. This lets OneLake/ADLS writes ignore configured remote write bandwidth limits. Please throttle to_append before each upload chunk.
  • [src/Disks/IO/WriteBufferFromAzureDataLakeStorage.cpp:163] runWithRetries executes ADLS network operations without the write ResourceGuard used by WriteBufferFromAzureBlobStorage::execWithRetry. That bypasses configured I/O scheduling limits for the new write path. Please wrap Create, Append, and Flush with the same write resource accounting, with byte cost for Append.
  • [src/Disks/IO/WriteBufferFromAzureDataLakeStorage.cpp:66] [dismissed by author -- https://github.com/Support azure datalake storage gen2 writer #105406#discussion_r3350311650] isAdlsGen2Endpoint still only matches Fabric hosts, so normal ADLS Gen2 endpoints such as *.dfs.core.windows.net keep using the Blob writer. That conflicts with the PR title/changelog promising Azure Data Lake Storage Gen2 writer support. Please either support the standard ADLS Gen2 DFS host or narrow the code name and changelog to OneLake/Fabric.
Tests
  • ⚠️ [src/Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage/AzureObjectStorage.cpp:306] The new ADLS/OneLake writer branch has no focused test, and the existing OneLake INSERT e2e test is still xfail. Please add the smallest test that writes through this branch end to end, or un-xfail/adapt the OneLake insert test so endpoint selection, auth/SAS handling, prefix handling, finalize/cancel, and delete cleanup are covered.
Final Verdict

Status: ❌ Block

Minimum required actions: fix the unsafe rollback behavior for existing-object rewrites, preserve the existing Azure write durability/accounting controls on the ADLS branch, and add focused coverage for the new writer path.

@clickhouse-gh clickhouse-gh Bot added pr-feature Pull request with new product feature submodule changed At least one submodule changed in this PR. labels May 20, 2026
@CLAassistant

CLAassistant commented May 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@scanhex12
scanhex12 marked this pull request as ready for review May 21, 2026 10:45
LOG_TRACE(log, "Flushed ADLS Gen2 file `{}` ({} bytes)", blob_path, bytes_appended);
}

void WriteBufferFromAzureDataLakeStorage::finalizeImpl()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WriteBufferFromAzureDataLakeStorage ignores RequestSettings::check_objects_after_upload.

The Blob/S3 paths perform a post-finalize existence check when this flag is enabled, but the ADLS path always returns success after Flush without verifying object visibility. That silently weakens an existing durability check users explicitly opt into.

Please carry this setting into the ADLS writer and run a post-finalize GetProperties/GetProperties-equivalent check (throw on NotFound) the same way as WriteBufferFromAzureBlobStorage.

@asya-ch asya-ch self-assigned this May 21, 2026
if (to_append == 0)
return;

ensureCreated();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WriteBufferFromAzureBlobStorage and WriteBufferFromS3 both apply write_settings.remote_throttler to account/limit outbound bytes, but this ADLS path never does. As written, the isAdlsGen2Endpoint branch bypasses configured write throttling entirely.

Please apply throttling before each upload chunk (for example, in appendBufferedData, throttle to_append before Append).

LOG_INFO(log, "ADLS Gen2 {} attempt {} for `{}`", what, attempt, blob_path);
try
{
op();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runWithRetries executes ADLS network operations without the write ResourceGuard used by the Blob path (WriteBufferFromAzureBlobStorage::execWithRetry).

That means isAdlsGen2Endpoint uploads bypass write_settings.io_scheduling.write_resource_link accounting/limits, so ADLS writes are no longer governed by configured I/O scheduling controls.

Please apply the same ResourceGuard around these operations (at least Append with byte cost, and Create/Flush with zero cost) to preserve scheduler semantics.


auto hint_path = filename_generator.generateVersionHint();
if (!writeMetadataFileAndVersionHint(
if (!catalog && !writeMetadataFileAndVersionHint(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don’t need to update both the metadata on storage and the catalog metadata, since the catalog updates the metadata on storage by itself

We also don’t need to use the version hint file as a synchronization point, since the catalog does CAS

Comment thread src/Databases/DataLake/RestCatalog.h Resolved
pull Bot pushed a commit to sowelswl/ClickHouse that referenced this pull request Jun 7, 2026
The test was occasionally returning two rows from the per-iteration
SELECT against `system.query_log` instead of one, observed as a
spurious extra `1` in the diff before the expected `7` for
`max_threads = 7` iterations across multiple unrelated PRs (ClickHouse#101143,
ClickHouse#105406, ClickHouse#102308, ClickHouse#100752, ClickHouse#104473, ClickHouse#98779, ClickHouse#97302) and on master.

The original filter accepted any `type != 'QueryStart'` row matching
the iteration's `query_id`. Under randomized CI settings a second
`query_log` entry can match the same `query_id` (subquery, distributed
sub-fragment, or non-`Insert` follow-up), giving the test two rows.

Tighten the filter to require the successful initial INSERT only:
`type = 'QueryFinish' AND is_initial_query = 1 AND query_kind = 'Insert'`.
This matches the well-known sibling test `02871_peak_threads_usage`,
which already filters on `type = 'QueryFinish'`.

Verified locally that the new filter correctly suppresses a duplicate
log row sharing the same `query_id` while still returning exactly one
row for the real INSERT.

CI report (one of the recent failures):
https://s3.amazonaws.com/clickhouse-test-reports/101143/

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@asya-ch asya-ch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good -- please do address the bot comment about adding the next() flush inside of finalizeImpl().

@scanhex12
scanhex12 enabled auto-merge June 9, 2026 09:39
blob_storage_log->local_path = object.local_path;
if (isAdlsGen2Endpoint(connection_params.endpoint))
{
return std::make_unique<WriteBufferFromAzureDataLakeStorage>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch adds a new ADLS/OneLake writer, but the PR does not add or enable a test that actually writes through it. The existing OneLake INSERT e2e test is still xfail, so endpoint selection, auth/SAS handling, prefix handling, finalize/cancel, and delete cleanup can regress without CI coverage.

Please add the smallest focused test that exercises this branch end to end, or un-xfail/adapt the OneLake insert test so the new writer is covered.

@clickhouse-gh

clickhouse-gh Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.60% 84.60% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.20% 77.20% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 23/193 (11.92%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code

Full report · Diff report

@scanhex12
scanhex12 added this pull request to the merge queue Jun 9, 2026
Merged via the queue into ClickHouse:master with commit cdea425 Jun 9, 2026
163 of 166 checks passed
@scanhex12
scanhex12 deleted the adlfs_gen2 branch June 9, 2026 15:40
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 9, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @scanhex12 — a couple of suggestions to make this PR easier for reviewers and the changelog reader.

Description (currently missing):

  • Why: The PR description is empty apart from the changelog category. It does not explain that the feature only activates for Microsoft Fabric endpoints, why the DataLake SDK is needed, that deletes fall back to single (non-batched) requests for ADLS, or how the feature was validated (no automated tests are included).

  • Suggested addition:

    This PR adds a WriteBufferFromAzureDataLakeStorage write path for the Azure object storage disk, used when the configured endpoint is a Microsoft Fabric ADLS Gen2 endpoint (dfs.fabric.microsoft.com / blob.fabric.microsoft.com). It uses the Azure DataLake SDK DataLakeFileClient Create/Append/Flush lifecycle with internal retries. Deletes for ADLS endpoints use single requests (the blob batch API is not used). Note: generic ADLS Gen2 endpoints (*.dfs.core.windows.net) are not covered by the detection. Please describe how this was tested against a real Fabric account, since no automated test can exercise the Fabric-only code path.

Ignore this if the current title/body is intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants