Repository navigation
fix(bigquery-jdbc): apply per-table expiration to generated LargeResultDataset temp tables - #15333
keshavdandeva wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces explicit tracking of destination dataset expiration times and implements a best-effort mechanism to set expiration times on generated temporary destination tables, including connection-level memoization of permission errors to avoid redundant API calls. The review feedback correctly identifies that setting the expiration time to Long.MAX_VALUE will result in a 400 Bad Request error from BigQuery, which has a maximum supported timestamp of 9999-12-31 23:59:59.999 UTC (253402300799000L). Capping the expiration time to this maximum value and updating the corresponding test assertion is recommended.
7906d4e to
9681094
Compare
7d63e05 to
863e0a5
Compare
…ltDataset temp tables
863e0a5 to
88ab641
Compare
9681094 to
24aaa5f
Compare
logachev
left a comment
There was a problem hiding this comment.
I think this is similar to previous. This feels like some hacking around the fact of "What if existing destinationDataset doesn't have TTL?".
I think this belongs to "missing API capabilities" category and we should discuss internally if we want to expose "TTL" via API rather than having each API user re-inventing ways to set TTL.
|
Closing per review feedback — setting per-table expiration via client-side |
b/584840569
Summary of Changes
LargeResultDestinations,BigQueryStatement):defaultTableLifetime > 0(including any dataset auto-created in PR 3), never calltables.update— the dataset's configured TTL is respected with zero extra RPCs.LargeResultDatasethas nodefaultTableLifetime(nullor<= 0, or when a409reload failed for a service account), best-effort patchexpirationTime = now + LargeResultsDatasetExpirationTime(default1h) on generated temporary tables (LargeResultTable == null) as a crash-leak safety net (b/584840569). ExplicitLargeResultTabletables are never patched.DataSource.javaorBigQuerySettings.java(no explicit-vs-default property tri-state).403 accessDeniedmemoization (LargeResultDestinations,BigQueryConnection):tables.updatenever fails query execution. If BigQuery returns HTTP403with reasonaccessDenied, memoize per connection so subsequent queries skiptables.update; non-IAM failures (503,403 rateLimitExceeded) log a warning without poisoning the connection.BigQueryConnection.resetForReuse()callslargeResultDestinations.resetForReuse()to clear memoized state on pooled connection reuse.USER_GUIDE.md,BigQueryStatementTest):null/zero/finite dataset TTLs,=0URL fallback,403 accessDeniedmemoization, non-IAM errors,resetForReuse(), and concurrentStatement.close()during table expiration.Decisions Taken & Open Review Points
LargeResultsDatasetExpirationTime=3600000(common in Simba URL templates) overrode a dataset's admin-configureddefaultTableLifetime. Always respecting finite dataset TTLs eliminates that footgun, eliminates changes toDataSource/BigQuerySettings, and keeps extra RPCs at zero for datasets with a TTL.1hdefault) on no-TTL datasets: On pre-existing datasets with nodefaultTableLifetime, settingexpirationTime = now + LargeResultsDatasetExpirationTime(default 1h) ensures temp tables expire even if the JVM crashes before PR 5'sResultSet.close()cleanup runs (b/584840569), at the cost that reads open longer than 1 hour on a no-TTL dataset require increasingLargeResultsDatasetExpirationTime(or setting a dataset TTL). Please weigh in if you prefer:LargeResultsDatasetExpirationTimedefault (1h),24h) when patching per-table expiration on no-TTL datasets, or