Skip to content

fix(bigquery-jdbc): add 1 GiB log file rotation and truncation fallback - #15165

Merged
Neenu1995 merged 1 commit into
mainfrom
fix/bq-jdbc-log-rotation-and-context
Nov 28, 2026
Merged

Neenu1995 merged 1 commit into
mainfrom
fix/bq-jdbc-log-rotation-and-context

Conversation

@Neenu1995

@Neenu1995 Neenu1995 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stack: PR 3 of 6 (base: fix/bq-jdbc-log-lock-and-interrupt)
Bug: b/584840147

Summary

Adds bounded 1 GiB log file size rotation onto a single .1.log (0600) backup file with in-place truncation fallback in PerConnectionFileHandler.

Environment Variables & System Properties

  • Added System Property: -Dcom.google.cloud.bigquery.jdbc.maxLogFileBytes=<bytes> (default: 1073741824 / 1 GiB). Documented in docs/USER_GUIDE.md.

Design Decisions

  • 1 GiB cap + single .1.log (0600) backup rotation: Validates .1.log with NOFOLLOW_LINKS (deleting any symlink without following it), atomically rotates active logs to .1.log, and opens a fresh 0600 active channel while preserving global sentinel locks.
  • In-place truncation fallback: Falls back to channel.truncate(0) when backup rotation is blocked.

@Neenu1995
Neenu1995 requested review from a team as code owners November 23, 2026 19:58

@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 diagnostic logging configuration and bounded log file rotation (using .log and .1.log backup files) configured via environment variables, JDBC URL properties, or JVM system properties. It also introduces ConnectionLogContext to carry per-connection logging identity and threshold safely across threads. The review feedback identifies two potential resource leaks in PerConnectionFileHandler.java where newly opened or recovered channels could be leaked if channel.size() throws an IOException during the rotation recovery or reopening phases.

@Neenu1995
Neenu1995 added this pull request to stack #15170 November 23, 2026 20:21
@Neenu1995 Neenu1995 changed the title [WIP] fix(bigquery-jdbc): add 1 GiB .1.log backup rotation and typed ConnectionLogContext fix(bigquery-jdbc): add 1 GiB .1.log backup rotation and typed ConnectionLogContext 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.

The typed ConnectionLogContext is clean, and rotation keeps contiguous history at 0600 on the normal path. One change is needed in rotate(), plus a few small items. The two bot comments at L551 / L572 can be resolved: the writer already owns the channel when size() is called.

@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-log-rotation-and-context branch from 8e67b02 to e7799af Compare November 26, 2026 20:35
@Neenu1995 Neenu1995 changed the title fix(bigquery-jdbc): add 1 GiB .1.log backup rotation and typed ConnectionLogContext fix(bigquery-jdbc): add 1 GiB log file rotation and truncation fallback 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-log-file-hardening to fix/bq-jdbc-log-lock-and-interrupt 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-log-rotation-and-context branch from e7799af to c43e958 Compare November 26, 2026 21:02
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-log-rotation-and-context branch from c43e958 to 97e53aa Compare November 27, 2026 00:51
@Neenu1995 Neenu1995 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 27, 2026
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-log-rotation-and-context branch 2 times, most recently from cfe82a4 to 0d3546b Compare November 27, 2026 22:55
@Neenu1995
Neenu1995 enabled stacked auto-merge (squash) November 28, 2026 00:34
stacked auto-merge was automatically disabled November 28, 2026 00:56

Auto-merge was disabled for another pull request in the stack

@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-log-rotation-and-context branch from 0d3546b to d56bab7 Compare November 28, 2026 00:56
Base automatically changed from fix/bq-jdbc-log-lock-and-interrupt to main November 28, 2026 01:17
@Neenu1995
Neenu1995 force-pushed the fix/bq-jdbc-log-rotation-and-context branch from d56bab7 to a7c105f Compare November 28, 2026 01:17
@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 a756d92 into main Nov 28, 2026
195 checks passed
@Neenu1995
Neenu1995 deleted the fix/bq-jdbc-log-rotation-and-context branch November 28, 2026 01:55
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