refactor(bigquery-jdbc): optimize thread management and unify discovery logic in DatabaseMetaData methods#13560
refactor(bigquery-jdbc): optimize thread management and unify discovery logic in DatabaseMetaData methods#13560keshavdandeva wants to merge 10 commits into
DatabaseMetaData methods#13560Conversation
…ry logic in `DatabaseMetaData` methods
There was a problem hiding this comment.
Code Review
This pull request refactors BigQueryDatabaseMetaData.java to clean up unused imports, correct catalog null-checks, consolidate dataset fetching logic into a helper method, and optimize getSchemas with a synchronous single-catalog path and a parallel multi-catalog path. The review feedback highlights several critical improvements: ensuring submitted futures are cancelled in the finally block of getSchemas to prevent resource leaks, wrapping project scans in a try-catch block to make sequential dataset fetching robust against single-project failures, restoring the thread's interrupted status when catching InterruptedException, and replacing an unnecessary Collections.synchronizedList with a plain ArrayList.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors metadata fetching in BigQueryDatabaseMetaData by consolidating dataset fetching into a helper method, introducing a synchronous path for single-catalog queries in getSchemas, and improving error handling. It also adds a null check in BigQueryJsonResultSet when cancelling tasks. The review comments point out three critical issues: a potential deadlock in the synchronous path of getSchemas when the schema count exceeds the bounded queue capacity, a compilation error due to a missing parameter in a BigQueryJsonResultSet.of call, and swallowed InterruptedException along with silent failures in the new fetchMatchingDatasets helper.
b/520407325
b/520406763
This PR refactors and optimizes the database metadata retrieval methods in the BigQuery JDBC driver. It resolves thread management inefficiencies, eliminates duplicate API blocks, ensures consistent project discovery support, and introduces consistent error propagation across all asynchronous metadata methods.
Key Changes
1. Catalog-Based Routing in
getSchemasgetSchemasnow executes completely synchronously on the calling thread, eliminating background executor and queue overhead.2. Unified Dataset Discovery & Deduplication
fetchMatchingDatasetsto serve as the sole entry point for listing and filtering datasets.getSchemas,getTables,getColumns,getProcedures,getProcedureColumns,getFunctions, andgetFunctionColumns), ensuring consistent support for project discovery and SQL wildcard matching across all of them.3. Robust Background Error Propagation & Deduplication
SQLException.