Skip to content

fix(bigquery-jdbc): isolate per-connection log levels, directories, and pre-connect routing - #15168

Merged
Neenu1995 merged 1 commit into
mainfrom
fix/bq-jdbc-per-conn-log-isolation
Nov 28, 2026
Merged

Neenu1995 merged 1 commit into
mainfrom
fix/bq-jdbc-per-conn-log-isolation

Conversation

@Neenu1995

@Neenu1995 Neenu1995 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stack: PR 5 of 6 (base: fix/bq-jdbc-connection-log-context)
Bug: b/584840083

Summary

Isolates per-connection LogLevel and LogPath configurations using reference-counted per-directory ManagedFileHandler instances, pre-connect global log scoping (openPreConnectScope), and ConnectionLogContext propagation through BigQueryJdbcMdc and OpenTelemetryJulHandler.

Design Decisions

  • Reference-counted per-directory ManagedFileHandlers: Concurrent connections maintain independent thresholds and directories without closing sibling handlers or detaching OpenTelemetryJulHandler.
  • Scoped pre-connect routing (openPreConnectScope): Routes pre-UUID connection diagnostics to the target LogPaths BQ-JDBC-GLOBAL.log and releases handlers deterministically.
  • Thread-pool & OTel per-connection level isolation: Propagates ConnectionLogContext across BigQueryJdbcMdc executors and enforces per-connection level thresholds in OpenTelemetryJulHandler.

@Neenu1995
Neenu1995 requested review from a team as code owners November 23, 2026 20:01

@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 updates the BigQuery JDBC driver's logging mechanism to support per-connection logging levels and paths, introducing PerConnectionFileHandler and updating BigQueryJdbcRootLogger to dynamically manage active connections and handle external handlers. The review feedback suggests two key improvements: passing the exception object directly to logger.log instead of using string concatenation to preserve the stack trace, and explicitly resetting several static fields in resetForTesting() to prevent state leakage and ensure test isolation.

@Neenu1995
Neenu1995 added this pull request to stack #15170 November 23, 2026 20:21
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from 63f8a7c to 3b01d92 Compare November 23, 2026 20:23
@Neenu1995
Neenu1995 requested a review from a team as a code owner November 23, 2026 20:23
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from 3b01d92 to a209aeb Compare November 23, 2026 20:58
@Neenu1995 Neenu1995 changed the title [WIP] fix(bigquery-jdbc): isolate per-connection log handlers with graceful path degradation fix(bigquery-jdbc): isolate per-connection log handlers with graceful path degradation Nov 24, 2026
@Neenu1995

Copy link
Copy Markdown
Contributor Author

/gcbrun

@keshavdandeva keshavdandeva 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.

Isolation works. Repro: three connections with different LogLevel / LogPath each got only their own records, a LogLevel=0 connect no longer strips other handlers, and the PR 4 handler-removal problem is fixed. The failure path needs work: one failed open now ends a connection's log for good, and almost nothing is reported.

@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from cad2b7c to b585440 Compare November 26, 2026 20:35
@Neenu1995
Neenu1995 requested review from a team as code owners November 26, 2026 20:35
@Neenu1995 Neenu1995 changed the title fix(bigquery-jdbc): isolate per-connection log handlers with graceful path degradation fix(bigquery-jdbc): isolate per-connection log levels, directories, and pre-connect routing Nov 26, 2026
@Neenu1995
Neenu1995 removed this pull request from stack #15170 November 26, 2026 20:52
@Neenu1995
Neenu1995 changed the base branch from fix/bq-jdbc-url-log-masking to fix/bq-jdbc-connection-log-context November 26, 2026 20:52
@Neenu1995
Neenu1995 added this pull request to stack #15256 November 26, 2026 20:52
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from b585440 to 3627d89 Compare November 26, 2026 21:02
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from 3627d89 to 0d258e6 Compare November 27, 2026 00:52
@Neenu1995 Neenu1995 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 27, 2026
private static String canonicalPathKey(String logPath) {
String normalized = logPath == null ? "" : logPath;
try {
return Paths.get(normalized).toAbsolutePath().normalize().toString();

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.

Nit. normalize() does not resolve symlinks, so one directory reached by two spellings gets two handlers and a second global log file (reproduced). Keying by the real path, once the handler has created the directory, avoids that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping canonicalPathKey purely lexical (toAbsolutePath().normalize()) avoids performing blocking toRealPath() (lstat/readlink) syscalls while holding the global HANDLER_LOCK on every openPreConnectScope and registerConnection cache lookup (which could stall concurrent connect() calls on networked filesystems). In the edge case where one JVM simultaneously configures two different symlink alias spellings for the same directory, openGlobalChannel already canonicalizes via logDir.toRealPath() in ACTIVE_GLOBAL_PATHS, preventing any lock or file-write collision on BQ-JDBC-GLOBAL.log while per-connection files still write cleanly to the directory.

@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from 0d258e6 to 3026a0d Compare November 27, 2026 16:11
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from 3026a0d to 5646d03 Compare November 28, 2026 00:20
@Neenu1995
Neenu1995 enabled stacked auto-merge (squash) November 28, 2026 00:34
@Neenu1995
Neenu1995 disabled stacked auto-merge November 28, 2026 00:56
Base automatically changed from fix/bq-jdbc-connection-log-context to main November 28, 2026 02:27
@Neenu1995 Neenu1995 added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Nov 28, 2026
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-per-conn-log-isolation branch from 5646d03 to 1ec4247 Compare November 28, 2026 03:15
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 28, 2026
@Neenu1995
Neenu1995 merged commit 35ae16b into main Nov 28, 2026
195 checks passed
@Neenu1995
Neenu1995 deleted the fix/bq-jdbc-per-conn-log-isolation branch November 28, 2026 03:47
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.

3 participants