Skip to content

Revert "Fix polaris catalog with azure" - #102247

Merged
tavplubix merged 1 commit into
masterfrom
revert-100583-fix_iceberg_polaris
Apr 9, 2026
Merged

tavplubix merged 1 commit into
masterfrom
revert-100583-fix_iceberg_polaris

Conversation

@tavplubix

@tavplubix tavplubix commented Apr 9, 2026 •

Copy link
Copy Markdown
Member

Reverts #100583

cc @scanhex12

Version info

  • Merged into: 26.4.1.719

@clickhouse-gh

clickhouse-gh Bot commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [53cc50a]


AI Review

Summary

This PR reverts prior Azure/Polaris handling in DataLake table metadata path logic. I found two correctness regressions introduced by the revert: one undefined-behavior out-of-bounds read in getMetadataLocation, and one endpoint normalization mismatch that can break metadata path extraction for valid endpoint values with trailing slash. Verdict: request changes before merge.

PR Metadata
  • ⚠️ Changelog category / Changelog entry are not present in the PR body (template fields are missing).
  • Suggested replacement text (minimal):
    • Changelog category (leave one): CI Fix or improvement
    • Changelog entry: Revert Azure/Polaris ABFSS path handling changes from #100583 due to correctness regressions in DataLake metadata-path processing.
Findings

❌ Blockers

  • [src/Databases/DataLake/ICatalog.cpp:266] metadata_location[data_location.size()] is accessed without checking that metadata_location is longer than data_location. When both strings are equal, starts_with is true and this becomes a one-past-end read (undefined behavior).

    • Suggested fix: restore the length guard before indexing, e.g. metadata_location.size() > data_location.size() && ....
  • [src/Databases/DataLake/ICatalog.cpp:261] Endpoint prefix stripping now compares against raw endpoint, while location construction normalizes trailing /. With endpoint='https://account.dfs.core.windows.net/', data_location may be https://account.dfs.core.windows.net/... (no trailing slash), so starts_with(endpoint) fails and relative metadata extraction breaks.

    • Suggested fix: normalize endpoint in getMetadataLocation (same as before) before starts_with/substr logic.
Tests
  • ⚠️ Add a test where metadata_location == data_location to ensure no out-of-bounds read in slash-removal logic.
  • ⚠️ Add/restore an endpoint test with trailing slash (https://.../) to verify metadata relative path extraction remains correct.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ⚠️ Coverage for reverted Azure/Polaris edge cases was removed; key edge-case behavior is now untested.
Experimental gate ➖
No magic constants ✅
Backward compatibility ⚠️ Endpoint normalization behavior regresses for valid trailing-slash endpoint values.
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ PR template changelog fields are missing.
Safe rollout ⚠️ Current regressions make rollout unsafe until fixed.
Compilation time ✅
No large/binary files ✅
Performance & Safety
  • Safety concern: one new UB read in a metadata-path hot control flow (getMetadataLocation) must be fixed before merge.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Fix the out-of-bounds access in getMetadataLocation.
    2. Restore endpoint normalization consistency for trailing-slash endpoints.
    3. Add/restore tests covering both edge cases above.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Apr 9, 2026
if (metadata_location.starts_with(data_location))
{
size_t remove_slash = (metadata_location.size() > data_location.size() && metadata_location[data_location.size()] == '/') ? 1 : 0;
size_t remove_slash = metadata_location[data_location.size()] == '/' ? 1 : 0;

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.

metadata_location[data_location.size()] can read one past the end when metadata_location == data_location.

starts_with is still true in that case, so this access is out-of-bounds and introduces undefined behavior. Please restore a bounds check before indexing (for example, check metadata_location.size() > data_location.size() first).

if (!endpoint.empty() && metadata_location.starts_with(azure_host_prefix))
metadata_location = "/" + bucket + "/" + metadata_location.substr(azure_host_prefix.size());
}
else if (!endpoint.empty() && data_location.starts_with(endpoint))

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.

constructLocation normalizes endpoint by removing a trailing /, but this comparison now uses the raw endpoint value.

If the setting is configured as https://account.dfs.core.windows.net/, data_location starts with https://account.dfs.core.windows.net (without trailing slash), so starts_with(endpoint) becomes false and prefix stripping is skipped. That breaks relative metadata path extraction for valid endpoint values differing only by trailing slash.

@tavplubix
tavplubix enabled auto-merge April 9, 2026 16:02
@tavplubix
tavplubix added this pull request to the merge queue Apr 9, 2026
Merged via the queue into master with commit c4d06e7 Apr 9, 2026
54 of 140 checks passed
@tavplubix
tavplubix deleted the revert-100583-fix_iceberg_polaris branch April 9, 2026 16:14
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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.

2 participants