Skip to content

Fix flaky test_e2e_catalogs[glue]: implement wait_for_table_ready - #108604

Merged
nikitamikhaylov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-test-e2e-catalogs-glue-wait-for-table-ready
Jul 16, 2026
Merged

nikitamikhaylov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-test-e2e-catalogs-glue-wait-for-table-ready

Conversation

@groeneai

@groeneai groeneai commented Jun 26, 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 a flaky failure in test_e2e_catalogs on the AWS Glue backend that surfaces as:

AssertionError: Table 'tbl_xxxxxxxx' not found in SHOW TABLES output:

AwsGlueCatalogManager.wait_for_table_ready and wait_for_table_gone were bare pass
no-ops, whereas the sibling BigLakeCatalogManager and OneLakeCatalogManager implement
them as bounded pyiceberg polling loops. The module-scoped fixtures (sales_table,
customers_table, types_table, complex_table) and several tests call
wait_for_table_ready(name) right after create_table, expecting it to block until the
table is catalog-visible.

AWS Glue is eventually-consistent for GetTables listing (GlueCatalog::getTablesForDatabase
issues a GetTables call per query with no server-side cache), so for the glue backend the
no-op returned immediately and the first resolve_table_name / SHOW TABLES could race
ahead of Glue's listing propagation. resolve_table_name retries for ~15s, which was not
always enough.

This implements both methods to poll self.catalog (pyiceberg glue) until the table is
loadable AND listed (ready) or load_table raises (gone), bounded by a wall-clock deadline,
mirroring the proven BigLakeCatalogManager / OneLakeCatalogManager pattern. Glue places
each table in its own namespace, so _namespace_for resolves the namespace from
_tables_created. Test assertions and resolve_table_name's existing retry backstop are
unchanged.

Note: the [glue] E2E job requires real AWS Glue credentials and does not run on the public
CI dashboard.

Version info

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

AwsGlueCatalogManager.wait_for_table_ready and wait_for_table_gone were
bare `pass` no-ops, while the sibling BigLake and OneLake managers
implement them as bounded pyiceberg polling loops. The module-scoped
fixtures (sales_table, customers_table, types_table, complex_table) and
several tests call wait_for_table_ready(name) right after create_table
expecting it to block until the table is catalog-visible.

AWS Glue is eventually-consistent for GetTables listing
(GlueCatalog::getTablesForDatabase issues a GetTables call per query with
no server-side cache), so for the glue backend the no-op returned
immediately and the first resolve_table_name / SHOW TABLES could race
ahead of Glue's listing propagation. resolve_table_name retries for
~15s, which was not always enough, surfacing intermittently as:

  AssertionError: Table 'tbl_xxxxxxxx' not found in SHOW TABLES output:

Implement both methods to poll self.catalog (pyiceberg glue) until the
table is loadable AND listed (ready) or load_table raises (gone), bounded
by a wall-clock deadline, mirroring the proven BigLakeCatalogManager /
OneLakeCatalogManager pattern. Glue places each table in its own
namespace, so _namespace_for resolves the namespace from _tables_created.
Assertions and resolve_table_name's existing retry are unchanged.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The [glue] E2E job needs real AWS Glue credentials and does not run on public CI, so no local run. The defect is not speculative though: wait_for_table_ready/wait_for_table_gone are literally pass on HEAD (directly observable), and the failure report (AssertionError: Table '...' not found in SHOW TABLES) plus two proven sibling implementations establish the mechanism.
b Root cause explained? Module-scoped fixtures call wait_for_table_ready(name) right after create_table, expecting it to block until the table is catalog-visible. For glue it is a no-op and returns instantly. AWS Glue GetTables is eventually-consistent (GlueCatalog::getTablesForDatabase issues a fresh GetTables per query, no server cache), so the first resolve_table_name/SHOW TABLES can race ahead of listing propagation; the existing ~15s retry is not always enough → intermittent AssertionError.
c Fix matches root cause? Yes. It makes wait_for_table_ready actually block (poll self.catalog.load_table + list_tables until visible) and wait_for_table_gone poll until load_table raises, bounded by a wall-clock deadline — directly closing the create→list propagation gap the fixtures already expected to be closed. No assertion weakening, no broad tag.
d Test intent preserved / new tests added? Preserved. All test assertions and resolve_table_name's retry backstop are unchanged; only the two no-op helpers gain real implementations. This is a test-harness correctness fix, so no product regression test applies.
e Both directions demonstrated? Not runnable without private AWS Glue credentials, so cannot demonstrate locally. The fix is backed by the observable no-op on HEAD and is a faithful port of the BigLake/OneLake implementations that already work for those eventually-consistent backends.
f Fix is general across code paths? Yes. The two no-ops were the only unimplemented members of the CatalogManager contract for the glue backend; the sibling backends (BigLake, OneLake) already implement the same contract. No other glue path needs the change.
g Fix generalizes across inputs? N/A (test-harness Python fix, not a server code/data-type bug).
h Backward compatible? N/A (integration-test helper only; no settings, formats, or user-visible behavior change).
i Invariants and contracts preserved? Yes. The implementation honors the CatalogManager.wait_for_table_ready/wait_for_table_gone contract ("block until queryable" / "block until gone") that the fixtures rely on, and uses the same bounded-deadline structure as the sibling managers. _namespace_for reads the existing _tables_created list; no shared-state mutation.

Session id: cron:clickhouse-worker-slot-0:20260626-120500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @fm4v — could you review? AwsGlueCatalogManager.wait_for_table_ready/wait_for_table_gone were pass no-ops while the fixtures call them right after create_table expecting a block until the table is catalog-visible; this implements them as bounded pyiceberg polls (load_table + list_tables / until load raises), mirroring the BigLake/OneLake managers, to stop the eventual-consistency race in test_e2e_catalogs[glue].

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fb1000f]

Summary: ✅


AI Review

Summary

This PR implements real wait helpers for the AWS Glue test_e2e_catalogs backend. Replacing the no-ops is the right direction, but the current checks still do not fully wait on the Glue listing paths that SHOW TABLES uses, so the original create/list and delete/list races can remain.

Missing context / blind spots
  • ⚠️ The [glue] e2e job requires private AWS Glue credentials, so I could not run the target test locally. A private run of the Glue backend after tightening the waits would close this gap.
Findings

⚠️ Majors

  • [tests/integration/helpers/catalog_manager_aws_glue.py:250] wait_for_table_ready returns after direct load_table and list_tables(namespace) see the table, but ClickHouse SHOW TABLES first enumerates Glue databases via GetDatabases. Because this helper creates a new namespace per table, a namespace that is not yet visible in that listing is skipped entirely, so the helper can still return before resolve_table_name can succeed. Suggested fix: also poll namespace/database listing until the created namespace is visible before returning ready.
  • [tests/integration/helpers/catalog_manager_aws_glue.py:292] wait_for_table_gone returns as soon as direct load_table raises, but the test immediately checks absence through SHOW TABLES, which is driven by GetDatabases and GetTables. A stale GetTables entry can still expose the dropped table after direct GetTable fails. Suggested fix: require both direct load failure and absence from list_tables(namespace) (or namespace disappearance) before returning gone.
Tests
  • ⚠️ Please provide a private Glue e2e run that covers table creation visibility and test_table_disappears_after_cleanup after the wait conditions are updated.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: wait for namespace visibility on create, wait for listing absence on delete, and verify with the private Glue e2e backend.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 26, 2026
attempt += 1
try:
self.catalog.load_table(identifier)
listed = self.catalog.list_tables(namespace)

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.

The ready condition still does not prove the contract the fixtures rely on. SHOW TABLES for Glue calls GlueCatalog::getTables, which first enumerates databases with GetDatabases and only then calls GetTables for each database. Since this helper creates a fresh Glue namespace per table, load_table(identifier) plus list_tables(namespace) can succeed while the namespace itself is still absent from the database listing, and ClickHouse will skip it completely. Please include the namespace-listing condition, for example poll list_namespaces/GetDatabases until namespace is present, before returning ready.

attempt += 1
try:
self.catalog.load_table(identifier)
except Exception:

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 returns as soon as direct load_table fails, but wait_for_table_gone is used immediately before SHOW TABLES assertions. SHOW TABLES is driven by Glue's listing path (GetDatabases -> GetTables), so a stale GetTables result can still list the dropped table even after direct GetTable/load_table has started failing. Please mirror the ready-side listing check and return only once the table is not loadable and list_tables(namespace) no longer contains it, or the namespace itself has disappeared.

pull Bot pushed a commit to Mattlk13/ClickHouse that referenced this pull request Jul 11, 2026
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]>
@nikitamikhaylov nikitamikhaylov self-assigned this Jul 16, 2026
@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue Jul 16, 2026
Merged via the queue into ClickHouse:master with commit 4d2ac0c Jul 16, 2026
168 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 16, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
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]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-test-e2e-catalogs-glue-wait-for-table-ready

Fix flaky test_e2e_catalogs[glue]: implement wait_for_table_ready
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.

3 participants