Skip to content

Add bounded retry to BigLakeCatalogManager.create_table - #109204

Merged
alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-biglake-create-table-bounded-retry
Jul 11, 2026
Merged

alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-biglake-create-table-bounded-retry

Conversation

@groeneai

@groeneai groeneai commented Jul 2, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

Fixes flaky test_e2e_catalogs/test.py::test_primitive_types[biglake] and
test_primitive_values[biglake]. Both share the module-scoped types_table
fixture, so both fail together when the fixture's create_table call fails.

Root cause. BigLakeCatalogManager.create_table in
tests/integration/helpers/catalog_manager_biglake.py performs the REST
catalog.create_table(...) + table.append(data) with no retry of its own.
pyiceberg 0.11.1's REST client retries only auth errors
(retry_if_exception_type((AuthorizationExpiredError, UnauthorizedError)),
stop_after_attempt(2), reraise=True), so a single transient BigLake blip
(ServerError / ServiceUnavailableError / CommitStateUnknownException,
or a connection reset) propagates straight out of create_table and errors the
shared fixture. The same file already guards this class of BigLake transience
with bounded wall-clock retry loops in wait_for_table_ready and
resolve_table_name; create_table was the gap.

Fix. Wrap create+append in a bounded wall-clock retry loop
(deadline = time.monotonic() + timeout, default 120s), mirroring the existing
wait_for_table_ready / resolve_table_name pattern. Only the specific
transient REST/network exceptions are retried; every other error (schema/config
bugs) still propagates immediately, so no real failure is masked. Each attempt
uses a fresh table name and best-effort drops a partially-created attempt, so a
retry after a partial success can neither resurface as TableAlreadyExistsError
nor duplicate the appended rows — creation stays exactly-once and no assertion is
weakened. After the deadline the last transient error is re-raised (fail-fast).

This is the create-path analogue of the glue listing-race fix (#108604): same
e2e-catalog helper family, same "cloud catalog transient error" theme, distinct
code path (create vs list) and backend (BigLake REST vs AWS Glue).

Validation. This E2E suite requires real BigLake / GCS credentials and does
not run in public CI, so there is no public CIDB signal and no local end-to-end
repro. The change is a defensive bounded-retry that completes an
already-established, already-reviewed pattern in the same file (it does not touch
any ClickHouse product code and masks no product bug). The retry control flow was
validated deterministically with a fake catalog injecting transient errors,
confirming all three directions: (1) the pre-fix single-attempt path raises on the
first transient blip; (2) the new path retries through transient blips and
succeeds, appending the data exactly once with no orphan tables; (3) the new path
re-raises the transient error once the deadline passes.

No related open issue found on the public tracker (private-CI-only E2E suite).

Version info

  • Merged into: 26.7.1.798 (included in 26.7 and later)

The e2e-catalog BigLake helper's create_table performs the REST
create_table + table.append with no retry of its own. pyiceberg's
REST client only retries auth errors (stop_after_attempt(2), reraise),
so a single transient BigLake blip (5xx ServerError,
ServiceUnavailableError, CommitStateUnknownException, connection reset)
propagates out and fails the module-scoped types_table fixture, taking
test_primitive_types[biglake] and test_primitive_values[biglake] down
together.

Wrap create+append in a bounded wall-clock retry loop, mirroring the
existing wait_for_table_ready and resolve_table_name patterns in the
same file. Only the specific transient REST/network exceptions are
retried; every other error still propagates immediately. Each attempt
uses a fresh table name and best-effort drops a partially-created
attempt, so a retry after a partial success can neither hit
TableAlreadyExistsError nor duplicate appended rows: table creation
stays exactly-once and no assertion is weakened. After the deadline the
last transient error is re-raised.

Create-path analogue of the glue listing-race fix (ClickHouse#108604).

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

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? No live BigLake repro possible (private-CI-only E2E suite, real GCS/BigLake creds). The retry control flow was proven deterministically with a fake catalog injecting transient ServiceUnavailableError: old path raises on the first blip, new path retries→succeeds, new path re-raises after the deadline.
b Root cause explained? create_table does catalog.create_table(...) + table.append(data) with no retry. pyiceberg 0.11.1's REST client retries only auth errors (stop_after_attempt(2), reraise=True), so a transient ServerError/ServiceUnavailableError/CommitStateUnknownException/connection-reset propagates out and errors the module-scoped types_table fixture, failing both [biglake] tests together.
c Fix matches root cause? Yes. Adds the missing bounded wall-clock retry around create+append, catching exactly the transient REST/network exceptions that pyiceberg does not retry. Not a band-aid: it addresses the identified "no bounded retry" gap directly.
d Test intent preserved? Yes. No assertion weakened, no no-* tag added, no data-size change. The table must still be genuinely created and made ready; only transient REST errors are tolerated. Non-transient errors still propagate immediately.
e Demonstrated in both directions? Yes (control flow): (1) pre-fix single-attempt raises on first transient blip; (2) new path retries through blips → succeeds, appends data exactly once, leaves no orphan tables; (3) new path re-raises the transient error after the deadline.
f Fix is general, not a narrow patch? Root cause is a resilience gap specific to create_table; the sibling paths in this file (wait_for_table_ready, resolve_table_name) already implement the same bounded-retry pattern, so this completes the family. Not guarding a symptom — the retry recovers from a genuine external cloud-service transient.
g Generalizes across inputs? Transient set covers the concrete pyiceberg 0.11.1 REST error classes (ServerError, ServiceUnavailableError, CommitStateUnknownException, AuthorizationExpiredError, OAuthError) plus requests.exceptions.RequestException (connection reset/timeout). Fresh-name-per-attempt keeps both the explicit-name and auto-name call forms exactly-once.
h Backward compatible? N/A — test-helper only; new params (timeout, poll_interval) are keyword-defaulted, and all existing callers pass only data, so no call site changes behavior.
i Invariants and contracts preserved? Yes. create_table's contract (return a short name for a genuinely-created, populated table) is upheld; exactly-once creation is preserved (fresh identifier per attempt + best-effort drop of a partial attempt → no TableAlreadyExistsError, no duplicate rows, no orphan tables); on exhaustion the last transient error is re-raised rather than swallowed.

Session id: cron:clickhouse-worker-slot-3:20260702-172300

@groeneai

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

cc @fm4v — could you review? BigLakeCatalogManager.create_table did the REST create_table + table.append with no retry, and pyiceberg's REST client only retries auth errors (stop_after_attempt(2)), so a single transient BigLake blip (5xx/connection-reset/commit-state-unknown) propagates out and fails the module-scoped types_table fixture, taking both [biglake] tests down together. This wraps create+append in a bounded wall-clock retry mirroring the existing wait_for_table_ready/resolve_table_name loops in the same file (fresh name per attempt + drop-on-fail → creation stays exactly-once, no assertion weakened). Create-path analogue of the glue fix #108604.

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

clickhouse-gh Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [628f554]

Summary: ✅


AI Review

Summary

This PR hardens BigLakeCatalogManager around transient BigLake failures: auto-named create_table calls now retry under a deadline, partial create attempts are reconciled instead of leaked, wait_for_table_gone no longer treats arbitrary load failures as proof of deletion, and the static-token RestCatalog paths now propagate auth-expiry instead of retrying or swallowing it. After reviewing the current code, the full thread history, and the final patch stack, I did not find any remaining correctness issues in the touched helper.

Missing context / blind spots
  • ⚠️ There is no public end-to-end signal for the real BigLake path here: the PR's public CI report contains 0 executed results, and this environment cannot run the private BigLake/GCS-backed integration suite. Confidence is therefore based on code inspection and the control-flow reasoning in the PR discussion, not on a live BigLake repro.
Final Verdict

✅ No new blocking issues found in the current diff.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 2, 2026
…ttempt

Review of the bounded-retry added to BigLakeCatalogManager.create_table
raised two correctness issues; both are fixed here.

1. Auth-expiry errors were pointless to retry. self.catalog is a RestCatalog
   built once in __init__ with a static bearer token; _refresh_token_if_needed
   refreshes only the separate GoogleOAuth2Credentials object and never pushes
   the new token into the already-created catalog, so retrying an expired token
   just resends the same stale token until the deadline. Rebuilding self.catalog
   mid-retry is unsafe because callers share it concurrently
   (test_many_tables_pagination fans create_table across a 10-thread pool).
   AuthorizationExpiredError and OAuthError are therefore dropped from the
   retried set and left to propagate.

2. Named creates were non-idempotent. The fresh-name-per-attempt guarantee only
   holds for the auto-generated path; a caller-supplied table_name is identical
   on every retry, so a retry after a partial success (create OK, append threw)
   could resurface as TableAlreadyExistsError or duplicate rows. Named creates
   now make a single attempt and let a transient error propagate as before,
   preserving the exact-short-name contract that test_many_tables_pagination
   asserts against SHOW TABLES. The bounded retry stays on the auto-generated
   path (the shared types_table fixture this change targets), which is idempotent.

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

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate for the review follow-up (commit 0f487b9). This is a test-helper resilience change; the E2E BigLake suite runs only in private CI with real GCS/BigLake credentials, so there is no public CIDB signal.

Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Control flow proven deterministically with a fake-catalog injection harness (.scratch/retry_logic_proof.py, all proofs pass). Live BigLake repro impossible (private-CI-only, real GCS/BigLake creds), same category as the accepted glue sibling #108604.
b Root cause explained? Two review findings. (1) self.catalog is a RestCatalog built once with a static bearer token; _refresh_token_if_needed refreshes only the separate GoogleOAuth2Credentials, so retrying an auth-expiry error just resends the stale token until the deadline. (2) The fresh-name-per-attempt guarantee held only for auto-generated names; a caller-supplied table_name was identical each retry, so a retry after a partial success (create OK, append threw) could resurface as TableAlreadyExistsError or duplicate rows.
c Fix matches root cause? (1) AuthorizationExpiredError and OAuthError dropped from _TRANSIENT_CREATE_ERRORS so auth expiry propagates immediately (rebuilding the shared catalog mid-retry is unsafe: test_many_tables_pagination uses it across a 10-thread pool). (2) Named creates make a single attempt; retry stays only on the auto-generated path.
d Test intent preserved / new tests added? Yes. No assertion weakened; the retry still genuinely creates and readies the table. Named creates keep the exact-short-name contract test_many_tables_pagination asserts against SHOW TABLES. Harness extended with two proofs: auth error not retried; named create is single-attempt, exactly-once, returns the requested short name.
e Both directions demonstrated? Harness proves: old single-attempt raises on the first blip; new auto path retries 3 blips then succeeds (append once, no orphan tables); new auto path re-raises after deadline; auth error propagates immediately (no sleep-until-deadline); named create with a transient append error propagates on attempt 1 (identifier created exactly once, not dropped).
f Fix is general across code paths? N/A (test-helper change, not a product code bug). The sibling resilience loops (wait_for_table_ready, resolve_table_name) already handle their own transience; this only closes the create_table gap.
g Fix generalizes across inputs? N/A (test-helper change, no datatype/wrapper surface). Both create paths (auto-generated and caller-supplied name) are covered.
h Backward compatible? Yes. create_table signature only gains keyword args timeout/poll_interval with defaults; all existing callers pass data (and optionally table_name) unchanged.
i Invariants and contracts preserved? Yes. Creation stays exactly-once on both paths (no orphan tables, no duplicate rows). Auth errors are no longer swallowed. self.catalog is never mutated concurrently. _tables_created bookkeeping records the live table on both paths.

Session id: cron:clickhouse-worker-slot-7:20260702-183100

After catalog.create_table commits, any later failure (append throwing a
non-transient error, or a CommitStateUnknownException from create itself)
previously left a live BigLake table behind: the auto-generated path only
dropped inside the transient handler, and the explicit-name path had no
handler at all. The leaked table was never tracked, so cleanup_all could not
empty the session namespace and test_list_tables_pagination saw stragglers.

Both branches now reconcile the partial attempt FIRST -- for every exception,
transient or not -- and only then decide retry (transient, auto path) vs
re-raise. _drop_failed_attempt drops the table if it can and otherwise records
it in _tables_created, so a drop that cannot be confirmed (BigLake async-index
lag makes a just-committed table briefly invisible) still gets reaped by the
end-of-session sweep. No table is ever leaked untracked.

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

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, for the control flow. Live BigLake repro is impossible here (private-CI-only E2E, needs real GCS/BigLake creds, same category as accepted glue sibling #108604). The leak is proven deterministically with a fake catalog injecting a non-transient append failure and an unconfirmable drop (.scratch/retry_logic_proof.py).
b Root cause explained? catalog.create_table commits before table.append runs. On the auto path, _drop_failed_attempt ran only inside the _TRANSIENT_CREATE_ERRORS handler; a non-retried exception (non-transient append error, or a CommitStateUnknownException after commit) re-raised without dropping or registering the table. The explicit-name branch had no handler at all. Result: a live table neither dropped nor recorded in _tables_created, so cleanup_all cannot empty the session namespace.
c Fix matches root cause? Yes. Both branches now catch every exception after create_table, reconcile the partial attempt first (_drop_failed_attempt), and only then decide retry (transient, auto path) vs re-raise. _drop_failed_attempt drops when it can and otherwise registers the name in _tables_created, so an unconfirmable drop (async-index lag) is still reaped by the end-of-session sweep.
d Test intent preserved / new tests added? Preserved. No assertion weakened. The auto path still retries transient errors exactly-once; the named path is still single-attempt with the exact short name. .scratch/retry_logic_proof.py extended with four invariants for this change (auto non-transient drop+re-raise, named non-transient drop+re-raise, unconfirmed-drop tracking, transient path with unconfirmed drops).
e Both directions demonstrated? Yes. Harness proves: OLD path leaks / raises without cleanup; NEW path drops-or-tracks the partial table on every failure and never leaves a table untracked (a computed leaked_untracked set is empty in all 12 cases). ALL PROOFS PASSED.
f Fix is general across code paths? Yes. Applied to BOTH create_table branches (auto-generated AND explicit-name), not just the one the bot pointed at. Traced upstream: the bad state is a committed-but-unfinalized table, reconciled at its origin (right after create) rather than guarded downstream.
g Fix generalizes across inputs? N/A (test-helper resilience change, not a product code bug). The reconcile path is exception-class agnostic (any Exception after create), so it covers all transient and non-transient error types uniformly.
h Backward compatible? N/A (test helper only; no product setting, format, or on-disk change).
i Invariants and contracts preserved? Yes. Invariant: every table catalog.create_table commits is either dropped or present in _tables_created before create_table returns or raises. Holds on all paths (success, transient retry, transient deadline, non-transient, unconfirmed drop). Auto path stays exactly-once; named path stays single-attempt with the caller's exact name.

Session id: cron:clickhouse-worker-slot-1:20260702-190700

The prior drop-or-track path registered an async-index-lagged partial table
in _tables_created so cleanup_all could reap it at teardown, but cleanup_all
itself did a single best-effort drop_table per tracked name and then cleared
_tables_created unconditionally. If the teardown drop also failed (still not
indexed, or a transient blip), the name was cleared anyway and the table was
leaked -- the same leak the tracking was meant to prevent, moved to teardown.

cleanup_all now retries each tracked-table drop under a bounded wall-clock
deadline and retains (never clears blindly) any name whose drop it could not
confirm; the namespace drop + GCS prefix delete remain the storage backstop.
A tracked table is forgotten ONLY on a confirmed drop_table return -- a raised
drop (transient error, or NoSuchTableError, which does not prove removal under
async-index lag) keeps the name for a later retry.

cleanup_table now untracks a table on a confirmed drop so cleanup_all does not
re-drop (and pointlessly retry) the already-removed tables that per-test
cleanup already handled (e.g. test_list_tables_pagination's 60 named tables);
a failed cleanup_table drop leaves the name tracked for cleanup_all to retry.

Author: Groene AI <[email protected]>

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

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes for the control flow via the fake-catalog harness (.scratch/retry_logic_proof.py): a tracked table whose drop_table keeps raising is deterministically forgotten by the OLD cleanup_all (unconditional clear) and deterministically retained by the NEW one. Live BigLake repro is impossible here (private-CI-only E2E, needs real GCS/BigLake creds; same category as accepted glue sibling #108604).
b Root cause explained? The prior drop-or-track path registered an async-index-lagged partial table in _tables_created for the teardown sweep, but cleanup_all did a single best-effort drop_table per name and then cleared _tables_created unconditionally. If that teardown drop also failed (not indexed yet / transient blip), the name was cleared anyway, so the tracked table was leaked -- the same leak, moved to teardown.
c Fix matches root cause? Yes. cleanup_all bound-retries each drop under a wall-clock deadline and forgets a name ONLY on a confirmed drop_table return; unconfirmed names are retained (never cleared blindly). _tables_created is reassigned to exactly the unconfirmed survivors.
d Test intent preserved / new tests? No product assertion touched (test-helper only). The harness gained 12 new invariants for this comment (retain-on-persistent-failure, retry-then-forget-on-confirmed, cleanup_table untrack-on-confirmed, failed-cleanup_table-retained-for-cleanup_all); all 12 prior invariants stay green (24 total).
e Demonstrated both directions? Yes. #4a: with the fix, a table whose drop keeps raising is RETAINED after the deadline (old code cleared it -> leak). #4b: an initially-failing drop is retried and, once it confirms, the name is drained to empty.
f Fix general, not a narrow patch? Covers both entry points to _tables_created: cleanup_all (retry + retain) and cleanup_table (untrack-on-confirmed so cleanup_all does not re-drop/​spin on the 60 already-removed pagination tables, and retain-on-fail so it retries). Mirrors the file's existing bounded wall-clock retry pattern (wait_for_table_ready, resolve_table_name).
g Generalizes across inputs? N/A (test-helper resilience, not a datatype/wrapper code path).
h Backward compatible? N/A (test helper; no product behavior, settings, or on-disk/wire format). cleanup_all gains optional timeout/poll_interval kwargs with defaults, so the no-arg call site (test.py teardown) is unchanged.
i Invariants preserved? Invariant strengthened and now holds through teardown: a table catalog.create_table committed is dropped OR present in _tables_created -- and a tracked name is removed ONLY once its drop is confirmed.

No public CI/CIDB signal (E2E needs real BigLake/GCS creds). Control flow validated by the fake-catalog harness (ALL 24 PROOFS PASSED). ASCII only, no product code touched.

Session id: cron:clickhouse-worker-slot-2:20260702-201000

The cleanup_all bounded-retry loop reran drop_table through the same
statically-tokened self.catalog. _refresh_token_if_needed refreshes only
the separate GoogleOAuth2Credentials, never the token baked into the
catalog, so once the token expired every retry resent the same stale
token: a long-running test_e2e_catalogs module would sit in teardown for
the full 120s deadline and still leave the tracked tables behind.

Mirror what create_table already does. Add a named _AUTH_EXPIRY_ERRORS set
(AuthorizationExpiredError, OAuthError, UnauthorizedError -- the same set
pyiceberg's own REST client retries-then-reraises) and:

- _drop_confirmed re-raises auth-expiry instead of retaining-and-retrying.
- cleanup_all catches it, stops the deadline loop immediately (no burn),
  keeps every tracked table (never cleared), still runs the GCS storage
  backstop (it builds a fresh gcsfs client from the refreshed credential,
  so it can still reap the data files), and propagates so the teardown
  failure is visible.

Rebuilding self.catalog mid-retry was rejected in the create_table thread:
callers share it concurrently (test_many_tables_pagination fans it across a
10-thread pool), so the consistent resolution is auth-expiry-non-retryable.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The _AUTH_EXPIRY_ERRORS contract (auth-expiry is non-retryable for the
static-token RestCatalog: self.catalog cannot pick up a refreshed token)
was applied to create_table and cleanup_all, but the two polling helpers
still treated auth-expiry as transient:

  wait_for_table_ready (test_many_tables_pagination path): caught the
  auth-expiry from load_table/list_tables in its generic handler and slept
  to the 120s deadline, so a mid-module token expiry burned two minutes for
  nothing.

  wait_for_table_gone (test_table_disappears_after_cleanup path): caught the
  same in its generic handler and returned success as if the table had
  disappeared, a false-positive cleanup that masks a still-present table.

Both now catch _AUTH_EXPIRY_ERRORS before the generic handler and re-raise
immediately, matching create_table/cleanup_all. Genuine transient errors
keep the bounded-retry behavior, and a genuine load failure in
wait_for_table_gone still means the table is gone.
…pace

wait_for_table_gone previously treated ANY load_table exception as proof the
table was gone, so a transient 5xx / connection-reset (the class create_table
retries) produced a false-positive cleanup on the test_table_disappears_after
_cleanup path. Now only a genuine not-found (_TABLE_GONE_ERRORS =
NoSuchTableError, NoSuchNamespaceError) confirms removal; a transient failure is
retried under the deadline and surfaces as TimeoutError.

cleanup_all's final drop_namespace ran through the static-token catalog with a
bare except Exception: pass, swallowing auth expiry. When pending is empty (the
common case, since cleanup_table untracks confirmed drops) or the token expires
after the per-table loop, that was the only remaining catalog call and its auth
failure was silently lost. It now applies the same _AUTH_EXPIRY_ERRORS contract
as the loop: run the GCS storage backstop, then propagate.

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

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the two review comments in 628f554 (2 changes, both in tests/integration/helpers/catalog_manager_biglake.py).

Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Deterministic control-flow proof via the fake-catalog harness. CR#1: a scripted ServerError from load_table makes pre-fix wait_for_table_gone return "gone" after 1 call. CR#2: a scripted AuthorizationExpiredError from drop_namespace (with pending empty) is swallowed pre-fix. The BigLake E2E suite is private-CI-only (real GCP creds), so there is no public CIDB signal; validation is deterministic control-flow, same category as the accepted glue sibling.
b Root cause explained? Yes. self.catalog is a RestCatalog built once with a static bearer token that _refresh_token_if_needed cannot update in place. (1) wait_for_table_gone's generic except Exception: return treated ANY load_table failure -- including the transient 5xx/connection-reset class create_table retries -- as proof the table was gone, so a teardown blip -> false-positive cleanup. (2) cleanup_all's final drop_namespace had a bare except Exception: pass; since cleanup_table untracks confirmed drops, pending is usually empty and drop_namespace is the only remaining catalog call, so an expired-token auth failure there was silently lost.
c Fix matches root cause? Yes. (1) New _TABLE_GONE_ERRORS = (NoSuchTableError, NoSuchNamespaceError); wait_for_table_gone returns "gone" ONLY on those, retries every other error under the deadline. (2) The final drop_namespace now catches _AUTH_EXPIRY_ERRORS -> runs the GCS storage backstop then propagates, mirroring the per-table loop and create_table. No symptom-masking.
d Test intent preserved / new tests added? Yes. Test-helper change; verified deterministically by the fake-catalog harness (real module, stubbed deps). Added cases W2c (transient load NOT gone), W2b2 (NoSuchNamespaceError still gone), K6 (drop_namespace auth-expiry propagates + GCS backstop), K6b (non-auth drop_namespace stays best-effort). 38/38 proofs pass; the prior C/K/W regression guards stay green.
e Both directions demonstrated? Yes. WITHOUT fix: W2c returns "gone" on a single ServerError (calls=1); K6 raises nothing (auth-expiry swallowed). WITH fix: W2c retries then raises TimeoutError (6 calls, 1.0s); K6 propagates the auth error and still runs the GCS backstop.
f Fix is general across code paths? Yes. Enumerated all 14 self.catalog.* call sites. The only two matching the flagged patterns are the two fixed here. _drop_confirmed intentionally treats NoSuchTableError as unconfirmed (drop semantics differ from existence-check semantics, documented). _cleanup_stale_namespaces is a best-effort startup sweep of OTHER sessions with no retry loop and no false-positive-gone contract, so its leniency is correct.
g Fix generalizes across inputs? N/A (test-helper control-flow fix, not a datatype/engine code bug). Both error tuples are matched by class, covering all subclasses.
h Backward compatible? N/A (private test helper; no user-facing behavior, settings, or on-disk/wire format).
i Invariants and contracts preserved? Yes. Auth-expiry-non-retryable is now applied consistently across create_table, wait_for_table_ready, wait_for_table_gone, the cleanup_all per-table loop, AND its final drop_namespace. The "never clear tracking blindly" and "GCS storage backstop always runs" invariants hold on every path incl. auth-expiry and error/early-return. self.catalog is never rebuilt mid-retry (callers share it concurrently).

Session id: cron:clickhouse-worker-slot-1:20260702-225000

@alexey-milovidov alexey-milovidov self-assigned this Jul 11, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 11, 2026
Merged via the queue into ClickHouse:master with commit 6fe38b3 Jul 11, 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 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-table-bounded-retry

Add bounded retry to BigLakeCatalogManager.create_table
clickgapai pushed a commit to clickgapai/ClickHouse that referenced this pull request Sep 27, 2026
test_e2e_catalogs::test_list_tables_pagination creates 60 tables through a
10-worker pool and passed an explicit table_name= to
BigLakeCatalogManager.create_table. That path is single-attempt by design:
PR ClickHouse#109204 added a wall-clock bounded retry to create_table but deliberately
carved the caller-supplied-name path out of it, because a same-name retry can
resurface its own partial attempt as TableAlreadyExistsError, so exactly-once
creation cannot be guaranteed there. That reasoning still holds.

The defect is that this test was the only table_name= call site in the whole
repo, so it made 60 un-retried live-catalog round-trips and failed whenever any
single one blipped. It does not actually need fixed names: it asserts set
membership of the names it created, whatever they are. So it now lets
create_table generate them and builds `expected` from the returned values.
Because every retry attempt uses a fresh unique name, exactly-once creation
holds by construction, which is precisely the property the carve-out protects,
and the fix therefore does not depend on _drop_failed_attempt being reliable
(it is best-effort by its own docstring).

The named branch is left in place and unchanged. After this change it has no
in-repo caller, but it is public helper API whose single-attempt contract is
still correct, so removing it would be an unrelated change.

Separately, NoSuchNamespaceError was retried by neither path. Its MRO is
[NoSuchNamespaceError, Exception, BaseException, object]: it is not a RESTError
and not a requests.RequestException, so it fell outside
_TRANSIENT_CREATE_ERRORS. BigLake indexes a just-created namespace
asynchronously, so the session namespace can 404 for a few seconds after
create_namespace. Adding it to that tuple is safe: _TRANSIENT_CREATE_ERRORS is
consumed only by create_table, while the same class in _TABLE_GONE_ERRORS is
consumed only by wait_for_table_gone, so its "proof a table is gone" meaning
there is untouched. A namespace that is genuinely missing still fails with the
same exception, just at the existing deadline instead of immediately.

Validated by fault injection against the real functions, since a live run needs
GCS/BigLake credentials and the e2e suite is excluded from public CI: with
table_name= a transient error raises on attempt 1, and without it the same
error is retried and succeeds; reverting either change reddens its own arm,
while auth-expiry errors stay non-retryable. The three pagination assertions
from PR ClickHouse#104531 are untouched and still fail when the listing is truncated at
the page boundary, because detection rests on 60 tables exceeding one ~50-entry
page rather than on name sort order (measured identical at 2000 trials per
naming scheme). Auto-naming carries a 4.1e-07 collision probability per run,
and a collision raises TableAlreadyExistsError, which is not transient and so
fails loudly rather than silently.

Also fixes two comments naming a caller test_many_tables_pagination that has
never existed; the real caller is test_list_tables_pagination.
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-ci 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