Skip to content

Add opt-in redacted JDBC connection and operation diagnostics - #186

Draft
jamesqo wants to merge 1 commit into
mainfrom
codex/jdbc-diagnostics
Draft

jamesqo wants to merge 1 commit into
mainfrom
codex/jdbc-diagnostics

Conversation

@jamesqo

@jamesqo jamesqo commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Why

A validator-passing standby import failed with a ClickHouse JDBC SocketTimeoutException: Connect timed out during Connection.prepareStatement / clinical-attribute metadata lookup. We need to distinguish pool acquisition, preparation and execution failures without enabling global SQL/HTTP debug logging or changing retry behavior.

Changes

  • Add opt-in -Dcbio.jdbc.diagnostics=true at the shared JdbcUtil connection boundary; default returns the original connection unchanged.
  • Emit stderr events even when the standalone shaded JAR has no SLF4J provider: UTC/monotonic timings, process/connection/statement/event correlation IDs, calling DAO, DBCP pool occupancy/wait limits, configured host/port and allowlisted numeric URL timeouts.
  • Instrument standard JDBC preparation, execution, commit/rollback and close calls, preserving original driver exceptions and introducing no retries.
  • Record bounded cause/next/suppressed exception types, SQL states, vendor codes and stack locations without messages, SQL, arguments, result rows, credentials or full URLs.
  • Document activation, overhead, security boundary and limitations in docs/jdbc-diagnostics.md.

Validation

  • Java 21 / Maven: mvn package succeeds, 111 tests pass, including 10 new diagnostics tests.
  • Covers simulated acquisition/preparation/execution timeouts, exception identity, no retries, disabled-path identity, JDBC wrapper behavior, delegation/close, cyclic exception chains and redaction.
  • Shaded core-1.0.16.jar built locally; no database credentials or live DB needed for tests.
  • git diff --check passes.

Deliberate limits / draft status

This is an initial diagnostic layer, not a diagnosis or timeout fix. Host is configured, not the actual resolved/socket IP. URL timeouts are not claimed as effective driver defaults. Physical connection attempts, driver-internal retries, server query IDs, ResultSet iteration and vendor APIs reached via unwrap are not traced. Study/phase comes from surrounding importer logs. Existing application/driver logging is unchanged and may independently expose sensitive content: whole logs still need access controls.

No dependencies, timeouts, SQL or retry policy changed. This standalone PR is based on main and is separate from validator PR #183. No rollout image has been changed and no import rerun performed. Draft pending review and a controlled diagnostic-image reproduction; any rollout image must retain the separately validated validator changes.

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.

1 participant