feat: implement eager close ResultSet mode (enabled by default)#510
feat: implement eager close ResultSet mode (enabled by default)#510Copilot wants to merge 9 commits into
Conversation
Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/362d48ba-eaaf-451b-9617-705d092cbbd3 Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/362d48ba-eaaf-451b-9617-705d092cbbd3 Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
|
@copilot change to be enabled by default. |
Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/4627f391-411a-4cc0-b65f-90b24ef56261 Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
|
@copilot appears to be closing the ResultSet before it is finished reading, also might need to have special treatment for LOBs/binary streams Error: Failures: |
|
@copilot lets use a different name it should not be materialized result set, should be something like eagerly close result sets. |
…n materialized mode Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/ae782555-9b2c-4b4c-b0ec-83db007207bb Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Fixed in 40ea888. The root causes were three overly-aggressive releases in
All three early-release paths have been removed. The feature flag ( Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
… mode Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/028f4922-d244-4227-b13a-f7ffdb7d0782 Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Done in 26548d1. Renamed throughout:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Done in c580aec. There was one conflict in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…LOBs and auto-commit When eagerClose is enabled and the ResultSet is fully read with: - no LOBs/binary streams registered in the session - not inside a transaction (auto-commit = true) - not an XA session - not DB2 (which requires post-iteration metadata lookups from session) ... the server now closes the RS, closes the Statement, and terminates the session (returning the pooled connection immediately). SessionManagerImpl getters are now null-safe so that subsequent close() calls from the JDBC client on an already-terminated session return an empty success response rather than NPE-ing. CallResourceAction handles null resources (eagerly-closed sessions) by returning an empty success response, preventing JDBC close() calls from surfacing as errors in the application. Tests updated: 6 unit tests covering disabled mode, eager termination, client close after eager close, RS/Statement closure, active-transaction guard, and LOBs guard." Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/0b450291-612a-4892-a955-533a837b2e3a Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…ob in test Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/0b450291-612a-4892-a955-533a837b2e3a Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Done in fc05dd1. After a ResultSet is fully read, when To prevent the JDBC driver's subsequent Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot why are these still failing? I assumed in the path you implemented was safe to eagerly close the result set [INFO] Results: |
…t and connection preserved Agent-Logs-Url: https://github.com/Open-J-Proxy/ojp/sessions/df722726-7fbd-44bb-8b35-f63c291fbbc9 Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
|
Fixed in 1f85306. The path was not safe because
What the eager close now does: for a forward-only RS with no LOBs, in auto-commit, non-XA mode — the DB-side cursor is freed immediately after the stream completes rather than waiting for Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|



Implements the eager close ResultSet mode. When enabled (default), OJP proactively releases the DB-side cursor after a forward-only ResultSet is fully read by the client.
Enabled by default — set
ojp.resultset.eagerClose.enabled=falseto disable.Changes
ServerConfigurationojp.resultset.eagerClose.enabled(default:true)ResultSetHelper.handleResultSet()ResultSetcursor when all conditions are met:TYPE_FORWARD_ONLY(scrollable RS must stay open for client-side navigation methods)getMoreResults(), metadata access, etc.)shouldEagerClose()helper methodSessionManagerImplgetResultSet,getStatement,getPreparedStatement,getCallableStatement,getAttr,registerAttr) are null-safe, returningnull/no-op when the session has already been terminatedCallResourceActionnull, returns an empty success response so that subsequent JDBCclose()calls from the client do not surface as errors in the applicationCompatibility
eagerClose.enabled=true(default),TYPE_FORWARD_ONLYRS, no LOBs, auto-commit, non-XA, non-DB2eagerClose.enabled=true, scrollable RS / LOBs present / in transaction / XA / DB2eagerClose.enabled=falseTests
Six unit tests in
EagerCloseResultSetModeTest:shouldNotCloseResultSetEarlyWhenEagerCloseDisabled— mode off: RS left openshouldCloseForwardOnlyResultSetAfterFullyReadWithNoLobsAndAutoCommit— forward-only RS cursor closed; session remains aliveshouldAllowClientCloseCallAfterEagerClose—close()on an eagerly-closed RS returns successshouldCloseResultSetAfterEagerClose— RS is closed; Statement is not closedshouldNotReleaseConnectionWhenInsideActiveTransaction— no eager close whenautoCommit=falseshouldNotEagerCloseWhenSessionHasLobs— no eager close when LOBs are registeredAll 727 existing server tests pass. Checkstyle passes.