Skip to content

test(bigquery-jdbc): fix minor issues and run integration tests for otel#13866

Open
keshavdandeva wants to merge 5 commits into
jdbc/feature-branch-otelfrom
test-otel-in-presubmit
Open

test(bigquery-jdbc): fix minor issues and run integration tests for otel#13866
keshavdandeva wants to merge 5 commits into
jdbc/feature-branch-otelfrom
test-otel-in-presubmit

Conversation

@keshavdandeva

@keshavdandeva keshavdandeva commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

b/537284101

This PR fixes multiple OpenTelemetry resource leaks.

Key Changes

  1. Fix Thread Leaks (Reference Counting): Wrapped OpenTelemetrySdk in a CachedSdk to track usage. The SDK and its background threads are now explicitly closed when the last JDBC Connection using them is closed.
  2. Fix Classloader Leaks: Removed the redundant Runtime.addShutdownHook in BigQueryJdbcOpenTelemetry. This prevents severe Metaspace memory leaks when the driver is undeployed in Application Servers (like Tomcat/JBoss).
  3. Fix Service Account Path Fallback: Updated resolveEffectiveCredentials() to properly detect OAUTH_PVT_KEY_PATH_PROPERTY_NAME (key file paths), preventing erroneous fallbacks to Application Default Credentials.
  4. Fix Test Quota Limits: Increased the polling delay in ITOpenTelemetryTest from 500ms to 3000ms. This prevents the GCP Logging API from rejecting the test with RESOURCE_EXHAUSTED (Status 429) errors due to exceeding the 60 requests/minute quota limit.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request integrates OpenTelemetry tracing and logging into the BigQuery JDBC driver, introducing telemetry configuration management, context propagation across asynchronous boundaries, and GCP exporters. Key feedback highlights critical issues: a potential resource and thread leak from unclosed cached OpenTelemetrySdk instances, a violation of the java.util.Properties contract by passing a non-String object that could cause ClassCastExceptions in other drivers, a missing check for the private key path property during credential resolution, and classloader leaks in application servers caused by registering a JVM shutdown hook in a static initializer.

@keshavdandeva
keshavdandeva changed the base branch from main to jdbc/feature-branch-otel July 22, 2026 21:52
@keshavdandeva keshavdandeva changed the title test(bigquery-jdbc): testing presubmits - do not merge test(bigquery-jdbc): fix minor issues and run integration tests for otel Jul 22, 2026
@keshavdandeva

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces reference counting for OpenTelemetry SDK instances in the BigQuery JDBC driver to ensure proper resource cleanup when connections are closed. It adds a releaseSdk method, replaces the global shutdown hook with reference-tracked caching using a new CachedSdk class, and updates BigQueryConnection to release its SDK on close. In the test suite, polling retry limits and delays are increased to improve stability. The review feedback correctly identifies a potential race condition in releaseSdk where a newly cached SDK could have its reference count incorrectly decremented and closed prematurely; a check should be added inside computeIfPresent to verify the SDK instance before decrementing.

@keshavdandeva

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces reference counting for cached OpenTelemetry SDK instances in BigQueryJdbcOpenTelemetry to properly manage their lifecycle and close them when no longer needed, while also updating credential resolution logic in BigQueryConnection and adjusting integration test polling parameters. The review feedback suggests several key improvements: avoiding blocking sdk.close() calls inside ConcurrentHashMap compute lambdas to prevent locking issues, setting the connection's openTelemetry reference to null after release to prevent double-closing bugs, and initializing the SDK reference count to 1 by default to simplify instantiation.

@keshavdandeva
keshavdandeva marked this pull request as ready for review July 22, 2026 22:32
@keshavdandeva
keshavdandeva requested review from a team as code owners July 22, 2026 22:32
@keshavdandeva
keshavdandeva requested a review from logachev July 22, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant