Skip to content

Register Iceberg namespace in the catalog before writing table files (needed for SeaweedFS) - #114285

Merged
azat merged 2 commits into
ClickHouse:masterfrom
azat:iceberg-create-namespace-before-write
Aug 14, 2026
Merged

azat merged 2 commits into
ClickHouse:masterfrom
azat:iceberg-create-namespace-before-write

Conversation

@azat

@azat azat commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Files written first turn the namespace into a plain directory, which a catalog sharing the storage view (SeaweedFS) rejects with HTTP 500; the swallowed error left an orphaned metadata file that broke retries. Ensure the namespace before the first write; propagate failures except 404-then-create and 409 (REST) / AlreadyExists (Glue).

Example: https://pastila.nl/?01f91a25/620869a81af815ba6927860efbc72af4#NhE2Nbzh3AHhUHhA5Fdkzw==GCM

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):

Register Iceberg namespace in the catalog before writing table files (needed for SeaweedFS)

Version info

  • Merged into: 26.8.1.1402 (included in 26.8 and later)
  • Backported to: 26.7.6.14, 26.6.4.20, 26.5.8.19

@azat
azat requested review from Diskein and scanhex12 August 11, 2026 08:20
@clickhouse-gh

clickhouse-gh Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2012a0d]

Summary: ❌

job_name test_name status info comment
Integration tests (arm_binary, distributed plan, 1/4) FAIL
test_replicated_table_attach/test.py::test_startup_with_small_bg_pool_partitioned FAIL cidb
Stress test (amd_tsan) FAIL
Hung check failed, possible deadlock found FAIL cidb

AI Review

Summary

This PR fixes the SeaweedFS ordering bug by creating the namespace before the first metadata write and by tightening the REST error handling, but it also introduces a backward-incompatible GlueCatalog regression. CREATE TABLE can now fail for pre-provisioned Glue databases when the caller has permission to create tables but not to create databases, so the change is not ready to merge as-is.

Findings
  • ❌ Blocker: [src/Databases/DataLake/GlueCatalog.cpp:639] createNamespaceIfNotExists now throws on any CreateDatabase error except ALREADY_EXISTS. Before this PR, GlueCatalog::createTable ignored CreateDatabase failures and still attempted CreateTable, which allowed CREATE TABLE to succeed in an already existing Glue namespace even when the IAM principal lacked glue:CreateDatabase. Moving the call to IcebergMetadata::createInitial turns that previously supported permission model into an immediate failure before any table metadata is written. Suggested fix: check whether the Glue database already exists first, and only require CreateDatabase when it does not.
Tests
  • ⚠️ Please add a focused regression test for the Glue path, e.g. a fake-client/unit test where CreateDatabase returns AccessDenied for an already existing namespace and CreateTable would otherwise succeed. The new SeaweedFS integration test only exercises the REST catalog and will not catch this regression.
Final Verdict

❌ Changes requested.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.00% 79.00% +0.00%

Changed lines: Changed C/C++ lines covered: 33/44 (75.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 11, 2026
@alesapin alesapin self-assigned this Aug 11, 2026
`FileLock` is used unconditionally (port pool, docker network lock),
but was imported in the optional-deps try block, where any earlier
failing import (e.g. `psycopg2`) aborts it: NameError on local runs.

Example - https://pastila.nl/?004dba6d/d815bdc27fb4094ff84cac884f4f6edc#XrcrYzqskI1DupUaP0a+Ig==GCM
@azat
azat force-pushed the iceberg-create-namespace-before-write branch from b4d74f5 to e356a01 Compare August 11, 2026 11:43
Files written first turn the namespace into a plain directory, which a
catalog sharing the storage view (SeaweedFS) rejects with HTTP 500; the
swallowed error left an orphaned metadata file that broke retries.
Ensure the namespace before the first write; propagate failures except
404-then-create and 409 (REST) / AlreadyExists (Glue).

Co-Authored-By: Claude Fable 5 <[email protected]>
@azat
azat force-pushed the iceberg-create-namespace-before-write branch from e356a01 to 2012a0d Compare August 11, 2026 14:25
glue_client->CreateDatabase(create_request);
auto outcome = glue_client->CreateDatabase(create_request);
if (!outcome.IsSuccess() && outcome.GetError().GetErrorType() != Aws::Glue::GlueErrors::ALREADY_EXISTS)
{

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.

GlueCatalog::createNamespaceIfNotExists now turns every CreateDatabase error except ALREADY_EXISTS into a hard failure. Before this PR, GlueCatalog::createTable ignored CreateDatabase failures and still attempted CreateTable, which is what lets a principal create a table inside a pre-provisioned Glue database without glue:CreateDatabase. After moving the call into IcebergMetadata::createInitial, that valid permission model now aborts here even though the namespace already exists. Please mirror the REST approach here as well: first prove the namespace is absent (or otherwise distinguish AccessDenied on an existing namespace from a real create failure) before throwing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And it's okay and much better.

@azat
azat enabled auto-merge August 13, 2026 15:57
@azat

azat commented Aug 14, 2026 •

Copy link
Copy Markdown
Member Author

Stress test (amd_tsan)

Fixed already in #113397

@azat
azat added this pull request to the merge queue Aug 14, 2026
Merged via the queue into ClickHouse:master with commit 5c5dd13 Aug 14, 2026
352 of 356 checks passed
@azat
azat deleted the iceberg-create-namespace-before-write branch August 14, 2026 10:26
@azat

azat commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 14, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 14, 2026
Resolves one conflict in listTablesInNamespace. Master made createReadBuffer
virtual and dropped its default arguments (ClickHouse#114285, S3TablesCatalog SigV4
signing), so the three-argument call this branch had re-indented no longer
compiles. Took master's five-argument form at the indentation the branch's
try block requires; the tolerate-and-skip semantics are unchanged.
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 24, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 24, 2026
scanhex12 added a commit that referenced this pull request Aug 25, 2026
Backport #114285 to 26.7: Register Iceberg namespace in the catalog before writing table files (needed for SeaweedFS)
scanhex12 added a commit that referenced this pull request Aug 25, 2026
Backport #114285 to 26.6: Register Iceberg namespace in the catalog before writing table files (needed for SeaweedFS)
scanhex12 added a commit that referenced this pull request Aug 25, 2026
Backport #114285 to 26.5: Register Iceberg namespace in the catalog before writing table files (needed for SeaweedFS)
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 28, 2026
… catalog before writing table files (needed for SeaweedFS)
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 28, 2026
… catalog before writing table files (needed for SeaweedFS)
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 28, 2026
… catalog before writing table files (needed for SeaweedFS)
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants