Repository navigation
fix(bigquery-jdbc): isolate per-connection log levels, directories, and pre-connect routing - #15168
Conversation
There was a problem hiding this comment.
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.
63f8a7c to
3b01d92
Compare
3b01d92 to
a209aeb
Compare
|
/gcbrun |
keshavdandeva
left a comment
There was a problem hiding this comment.
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.
cad2b7c to
b585440
Compare
b585440 to
3627d89
Compare
3627d89 to
0d258e6
Compare
| private static String canonicalPathKey(String logPath) { | ||
| String normalized = logPath == null ? "" : logPath; | ||
| try { | ||
| return Paths.get(normalized).toAbsolutePath().normalize().toString(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
0d258e6 to
3026a0d
Compare
3026a0d to
5646d03
Compare
…nd pre-connect routing
5646d03 to
1ec4247
Compare
Stack: PR 5 of 6 (base:
fix/bq-jdbc-connection-log-context)Bug: b/584840083
Summary
Isolates per-connection
LogLevelandLogPathconfigurations using reference-counted per-directoryManagedFileHandlerinstances, pre-connect global log scoping (openPreConnectScope), andConnectionLogContextpropagation throughBigQueryJdbcMdcandOpenTelemetryJulHandler.Design Decisions
ManagedFileHandlers: Concurrent connections maintain independent thresholds and directories without closing sibling handlers or detachingOpenTelemetryJulHandler.openPreConnectScope): Routes pre-UUID connection diagnostics to the targetLogPathsBQ-JDBC-GLOBAL.logand releases handlers deterministically.ConnectionLogContextacrossBigQueryJdbcMdcexecutors and enforces per-connection level thresholds inOpenTelemetryJulHandler.