fix(bigquery-jdbc): lazy caller inference and zero-overhead coercion logging#13365
Open
Neenu1995 wants to merge 2 commits into
Open
fix(bigquery-jdbc): lazy caller inference and zero-overhead coercion logging#13365Neenu1995 wants to merge 2 commits into
Neenu1995 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces lazy caller inference in BigQueryJdbcCustomLogger by implementing a custom BigQueryJdbcLogRecord class, deferring expensive stack trace walks until they are actually needed. Additionally, BigQueryTypeCoercer was updated to use BigQueryJdbcResultSetLogger with lazy trace logging, and a unit test was added to verify the lazy evaluation. A review comment identified a potential thread-safety issue in BigQueryJdbcLogRecord where the lack of synchronization on getters, setters, and state-checking methods could lead to data races during asynchronous log processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the BigQuery JDBC driver is run with JUL-to-SLF4J bridges (like
SLF4JBridgeHandlerin Spring Boot environments), JUL's logging level is configured toALLto allow filtering to occur at the SLF4J/Logback layer. As a result, the driver's custom logger always proceeded to log, eagerly capturing and walking stack traces (new Throwable().getStackTrace()) to find the caller class and method. On hot paths (such asBigQueryTypeCoercer.coerceToconverting values for millions of rows), this caused severe CPU and memory overhead (representing up to ~99% CPU time in profile runs), even if SLF4J immediately discarded the logs.Summary of Changes
BigQueryJdbcLogRecord):BigQueryJdbcLogRecord(a custom subclass ofLogRecord) insideBigQueryJdbcCustomLoggerto defer caller stack-trace walking until requested by formatters/bridges.org.slf4j.bridge.*) to the caller skipper list to maintain inference correctness.BigQueryTypeCoercer):BigQueryJdbcResultSetLogger.effectiveLog.finestwith explicit context passing usingeffectiveLog.finestTrace("coerceTo", ...).testLazyCallerInferenceinBigQueryJdbcCustomLoggerTestto verify that stack-trace walking is deferred until queried and accurately resolves the correct caller class/method.Performance Impact
StackTraceElement[]on the JDBC data retrieval hot paths.