Skip to content

Fixes #37316: key BigQuery DDL cache by FQN for concurrent dataset safety - #37333

Merged
Khairajani merged 3 commits into
mainfrom
detail/bug-fix/fixes-37316-key-bigquery-ddl-cache-by-fqn-for-conc-890f41
Nov 19, 2026
Merged

Khairajani merged 3 commits into
mainfrom
detail/bug-fix/fixes-37316-key-bigquery-ddl-cache-by-fqn-for-conc-890f41

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #37316

I worked on the BigQuery metadata ingestion DDL prefetch cache because _table_ddl_cache was a plain dict keyed by bare table name and wiped with clear() at the start of every schema's prefetch. When threads > 1, the databaseSchema topology node processes multiple datasets concurrently on one shared BigquerySource instance, so a concurrent dataset's prefetch would clear/refill the shared cache — causing silent DDL loss (None returned) or cross-dataset DDL contamination (a table's schemaDefinition displaying another dataset's CREATE TABLE).

This is the same concurrency pattern that was fixed for the sibling _dataset_obj_cache/_table_obj_cache in #30974, but _table_ddl_cache (introduced earlier in #25471) was left untouched.

Type of change:

  • Bug fix

High-level design:

  • Each schema worker thread ingests one dataset at a time and reads each table's DDL once, so the DDLs now live in a threading.local() slot holding only that thread's current dataset (project.dataset key + {table: ddl}).
  • Prefetch replaces the slot instead of clearing a shared dict, so concurrent datasets never see or wipe each other's DDLs.
  • A read for a dataset the thread doesn't hold fetches it rather than returning None.
  • Memory is threads × one dataset, the same per thread as before. An earlier revision used a shared LRU (2048 tables, then 64 datasets); it either dropped DDLs on large datasets or kept finished ones, so it was replaced.

Tests:

Unit tests

  • I added unit tests for the new/changed logic.
  • test_bigquery.py: two real threads prefetching same-named tables concurrently each read their own DDL with no extra query (fails on main); a 5000-table dataset keeps every DDL; a read for a dataset the thread doesn't hold fetches it; per-schema isolation, uncached table returns None, prefetch failure and includeDDL=false paths.
  • test_bigquery_sharding.py: fixture updated for the thread-local slot.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion integration test changes — the bug requires includeDDL + threads > 1 + same-named tables across datasets, which is not covered by the existing integration test fixtures).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • Ran the BigQuery CLI E2E v2 tests (ingestion/tests/cli_e2e_v2/bigquery/test_metadata.py) but they could not execute — they require live GCP secrets (E2E_BQ_PRIVATE_KEY, E2E_BQ_PROJECT_ID, E2E_BQ_CLIENT_EMAIL, etc.) and a running OpenMetadata server, which are not available in this environment. The suite is designed to run via workflow_dispatch in CI with injected secrets.

UI screen recording:

Not applicable — backend-only ingestion source change with no UI impact.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
  • Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under docs/decisions/ (see its README.md). This description is gone from git log after the squash-merge.

Automatic Fixes PRs can be configured here.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues were found.

Summary

BigQuery ingestion now keeps table definitions separately for each worker, holding only its current dataset.

  • BigQuery schema workers now keep each dataset’s table DDLs separate.

Previous discussion: detail-app[bot] accepted whole-dataset memory use as a deliberate trade-off and left finer limits to maintainers. greptile-apps[bot] withdrew the earlier blocking cache finding.

Reviews (8) · Last reviewed commit: "ingestion: hold BigQuery DDLs per schema..." · Reviewed by Greptile

@detail-app
detail-app Bot requested a review from a team as a code owner November 6, 2026 23:12
@detail-app
detail-app Bot requested a review from Khairajani November 6, 2026 23:13
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Khairajani Khairajani added the safe to test Add this label to run secure Github workflows on PRs label Nov 18, 2026
detail-app Bot and others added 2 commits November 18, 2026 15:29
A 2048-entry per-table LRU dropped DDLs for datasets with more tables than
the cap, and for concurrent datasets whose combined size exceeded it. Cache
one dict per project.dataset instead, and re-fetch a dataset whose entry was
evicted rather than reporting its tables' DDL as missing.
@detail-app
detail-app Bot force-pushed the detail/bug-fix/fixes-37316-key-bigquery-ddl-cache-by-fqn-for-conc-890f41 branch from f409bdb to c3bb5dc Compare November 18, 2026 15:30
Each schema worker ingests one dataset at a time and reads each table's DDL
once, so a thread-local slot holding its current dataset bounds memory to
threads x one dataset, instead of up to 64 mostly-finished datasets in a
shared LRU. A read for a dataset the thread does not hold fetches it.
@Khairajani
Khairajani merged commit dbed533 into main Nov 19, 2026
58 checks passed
@Khairajani
Khairajani deleted the detail/bug-fix/fixes-37316-key-bigquery-ddl-cache-by-fqn-for-conc-890f41 branch November 19, 2026 13:26
Khairajani added a commit that referenced this pull request Nov 20, 2026
…set safety (#37333) (#38234)

Backport of #37333. Each schema worker thread holds only its current
dataset's DDLs in a thread-local slot, so concurrent datasets no longer
clear or overwrite each other's entries.

(cherry picked from commit dbed533)

Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] BigQuery ingestion: concurrent dataset processing corrupts or drops table DDL (includeDDL + threads>1)

3 participants