Repository navigation
Conversation
…g files PR 1 of 6 in the diagnostic logging series (b/584840147, part 1 of 3). Replaces java.util.logging.FileHandler inside PerConnectionFileHandler with an NIO SeekableByteChannel writer enforcing 0700/0600 POSIX permissions, symlink rejection, collision-safe exclusive creation, literal % path handling, and graceful ErrorManager degradation.
…tionLogContext PR 2 of 6 in the diagnostic logging series (b/584840147, part 2 of 3). Adds bounded 1 GiB two-file (.log + .1.log 0600 backup) rotation with graceful ErrorManager fallback to PerConnectionFileHandler, and replaces raw String LogRecord parameter stamping with typed ConnectionLogContext across BigQueryJdbcResultSetLogger and OpenTelemetryJulHandler.
…ion lifecycle PR 3 of 6 in the diagnostic logging series (b/584840147, part 3 of 3). Tracks active connections in BigQueryJdbcRootLogger with BigQueryConnection constructor finally cleanup and wraps per-connection writers in synchronized ConnectionFileSlot entries so post-close ResultSet/Struct calls and concurrent close() vs publish() calls do not reopen closed writers.
…tation-and-context
…log-handler-lifecycle
There was a problem hiding this comment.
Code Review
This pull request introduces robust connection lifecycle tracking and resource cleanup for the BigQuery JDBC driver, particularly around logging and executor services. It adds mechanisms to track active connections, register/unregister them, and refactors PerConnectionFileHandler to use a slot-based architecture (ConnectionFileSlot) to prevent resource leaks and ensure files are closed properly. Unit tests are also added to cover concurrency and post-close scenarios. The review feedback highlights two important improvements: first, fixing a potential issue in PerConnectionFileHandler where log records could be silently dropped if a slot is closed but the connection remains active; second, optimizing BigQueryJdbcResultSetLogger to default to OFF_VALUE for inactive connections to prevent unnecessary logging overhead.
…tation-and-context # Conflicts: # java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PerConnectionFileHandler.java
…log-handler-lifecycle # Conflicts: # java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PerConnectionFileHandler.java
…tation-and-context # Conflicts: # java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PerConnectionFileHandler.java
…log-handler-lifecycle
|
/gcbrun |
keshavdandeva
left a comment
There was a problem hiding this comment.
This does what it says. Repro: logging after close() no longer creates a file or leaks a descriptor, and 8 threads × 50 concurrent connects leave 1 handler (12–14 before). Two non-blocking comments inline. Please don't merge ahead of the PR 1 and PR 2 fixes. On the bot comment about a closed slot: the record isn't lost, it falls through to the default writer.
8e67b02 to
e7799af
Compare
Summary
PR 3 of 6 in the diagnostic logging stack (
b/584840147, part 3 of 3; stacked onfix/bq-jdbc-log-rotation-and-context). Tracks active connections inBigQueryJdbcRootLoggerand gates per-connection log writers behind synchronizedConnectionFileSlotlifecycle state so closed or failed connections never leak or reopen file descriptors.Environment Variables & System Properties
Design Decisions
BigQueryJdbcRootLoggermaintainsACTIVE_CONNECTIONSfor openBigQueryConnectioninstances, andBigQueryConnection's constructor cleans up its handler registration in afinallyblock if initialization throws before returning a connection.ConnectionFileSlotlifecycle: Wraps each connection'sBoundedLogFileWriterin aConnectionFileSlotwith avolatile closedflag checked both outside and inside synchronized slot methods (avoiding nested lock acquisition insideConcurrentHashMap.compute). OncecloseConnection(connectionId)runs, late logs from post-closeResultSet,Struct,Array, or concurrent worker threads cannot resurrect a closed log file.