Repository navigation
Description
Detail Bug Report
Introduced in #25471 by @keshavmohta09 on Jan 23, 2026
Summary
- Context: The BigQuery metadata ingestion source pre-fetches, per dataset, the
SHOW CREATE TABLEDDL of every table in one INFORMATION_SCHEMA query and attaches those DDLs to the ingestedTableentities as theirschemaDefinition. - Bug: The per-schema prefetch cache
BigquerySource._table_ddl_cacheis a plain instance-level dict keyed only by bare table name and is wiped withclear()at the start of every schema's prefetch, but thedatabaseSchematopology node processes multiple datasets concurrently on one sharedBigquerySourceinstance whenthreads > 1— so concurrent datasets overwrite each other's DDL cache entries. - Actual vs. expected: While a worker is still ingesting dataset A's tables, another worker's prefetch of dataset B clears the shared cache and refills it with B's rows; A's subsequent
get_schema_definitioncalls either returnNone(DDL silently dropped) or return dataset B's DDL for a same-named table, which is then published as dataset A's table definition — expected behavior is that every table gets its own dataset's DDL, as documented for the sibling caches which are keyed by fully qualified name for exactly this reason. - Impact: Silent data-quality corruption in the catalog: with
includeDDLenabled and multiple datasets containing same-named tables (e.g.ordersinsalesandanalytics), a table'sschemaDefinitioncan display aCREATE TABLEstatement belonging to a different dataset; simultaneously, other tables lose their DDL entirely with no error or warning.
Code with Bug
ingestion/src/metadata/ingestion/source/database/bigquery/metadata.py
def _prefetch_table_ddls(self, schema_name: str):
"""Pre-fetch all table DDLs at schema level using INFORMATION_SCHEMA"""
if not self.source_config.includeDDL:
return
self._table_ddl_cache.clear() # <-- BUG 🔴 clears shared cache while other schema threads still read it
...query INFORMATION_SCHEMA for THIS dataset...
for row in results:
self._table_ddl_cache[row.table_name] = row.ddl # <-- BUG 🔴 key is bare table name (collides across datasets)if self.source_config.includeDDL:
if self.sharding_enabled:
...
return self._table_ddl_cache.get(table_name) # <-- BUG 🔴 lookup by bare name can return None or another dataset's DDLExplanation
When threads > 1, the databaseSchema topology node processes multiple datasets concurrently using a single shared BigquerySource instance. _prefetch_table_ddls() runs once per dataset and (1) calls clear() on a shared dict and (2) stores DDLs keyed only by table_name. If another thread prefetches a different dataset while the first thread is still ingesting its tables, the second prefetch clears/refills the cache. Subsequent reads in the first thread then either miss (None, dropping DDL silently) or return the wrong dataset’s DDL when table names overlap.
Codebase Inconsistency
The same module documents that caches shared across concurrently processed schemas “must be keyed by the fully qualified name,” and sibling caches were fixed accordingly in 13acb7f0ab (#30974). _table_ddl_cache retains the unsafe wipe-and-refill + bare-name keying pattern.
Recommended Fix
Key the DDL cache by fully qualified name and avoid wiping shared state per schema; mirror the sibling-cache approach by using LRUCache and storing entries under project.dataset.table, then reading by the same FQN in get_schema_definition.
History
This bug was introduced in commit a992867320 ("Fixes #25359: Bigquery Ingestion Optimization (#25471)", 2026-01-23), which added schema-level DDL prefetching backed by a shared dict cleared/refilled per schema. A later commit (13acb7f0ab, #30974) fixed the same concurrency pattern for sibling caches but did not update _table_ddl_cache.
Activity
Fixes #37316: key BigQuery DDL cache by FQN for concurrent dataset sa…
Fixes open-metadata#37316: key BigQuery DDL cache by FQN for concurre…
[2.0] Fixes #37316: key BigQuery DDL cache by FQN for concurrent data…