Skip to content

Make JDBC Connection.close() async by default with synchronous opt-in#513

Merged
rrobetti merged 2 commits into
mainfrom
copilot/make-connection-close-async-configurable
May 14, 2026
Merged

Make JDBC Connection.close() async by default with synchronous opt-in#513
rrobetti merged 2 commits into
mainfrom
copilot/make-connection-close-async-configurable

Conversation

Copilot AI commented May 14, 2026

Copy link
Copy Markdown
Contributor

A recent change made OJP JDBC connection close fully synchronous, increasing close-path latency and coupling caller flow to terminate-session RPC completion. This update restores async close as the default while preserving a configurable synchronous mode.

  • Close semantics (driver runtime)

    • Connection.close() now defaults to asynchronous session termination.
    • Added opt-in synchronous behavior via ojp.jdbc.connection.close.synchronous=true.
    • Sync mode preserves prior blocking/error propagation behavior; async mode logs termination failures.
  • Configuration surface

    • New constant/property key: ojp.jdbc.connection.close.synchronous (default false).
    • Property is now recognized consistently across:
      • ojp.properties (including datasource-prefixed entries),
      • system properties / environment overrides,
      • DriverManager.getConnection(url, info) Properties.
  • Execution model

    • Async termination runs on a dedicated bounded daemon executor (instead of shared common pool) to isolate close-task scheduling.
  • Docs + contract updates

    • JDBC configuration docs updated to reflect async-by-default behavior and sync override.
    • Connection/property-loading unit coverage updated for the new close mode toggle.
# default behavior: async close (non-blocking)
ojp.jdbc.connection.close.synchronous=false

# opt in to blocking close semantics
ojp.jdbc.connection.close.synchronous=true

# datasource-scoped override
myApp.ojp.jdbc.connection.close.synchronous=true

Copilot AI and others added 2 commits May 14, 2026 08:10
@sonarqubecloud

Copy link
Copy Markdown

@rrobetti rrobetti marked this pull request as ready for review May 14, 2026 10:09
@rrobetti rrobetti merged commit 2b6a82e into main May 14, 2026
53 checks passed
@rrobetti rrobetti deleted the copilot/make-connection-close-async-configurable branch May 14, 2026 10:09
Copilot AI added a commit that referenced this pull request May 14, 2026
DEFAULT_JDBC_CLOSE_SYNCHRONOUS flipped from false to true.
The async-by-default introduced in PR #513 caused a race in Oracle tests
(ORA-00955) because terminateSession ran in the background, leaving the
previous session's table still locked when setUp tried to DROP+CREATE it.

- CommonConstants: DEFAULT_JDBC_CLOSE_SYNCHRONOUS = true
- ConnectionCloseBehaviorTest: tests updated to match synchronous default
- docs (ojp-jdbc-configuration.md, part2-chapter5-jdbc-configuration.md):
  updated default value and prose accordingly

Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/4838a8d8-f93e-4aba-844b-02e8203e6aa0

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
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.

2 participants