Repository navigation
Conversation
…ing them. `PostgresqlStatement` collects the encoded bind values before the extended query takes them over and releases them. A cancellation in between, typically from another thread while the result is being subscribed, dropped the collected values without releasing them, leaking a pooled buffer per bind value. Release the values the collection discards, as the query's message flow already does. [resolves pgjdbc#754]
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.
Issue description
Fixes #754.
A cancellation that arrives after a statement's bind values are encoded, but before the extended query takes them over, makes
collectBindingParameters(…)discard them without releasing them, leaking a pooled buffer per bind value. This releases the discarded values withdoOnDiscard(ReferenceCounted.class, ReferenceCountUtil::release), asPostgresqlStatementandExtendedFlowDelegatealready do for discarded frames.PostgresqlStatementUnitTests.executeCancelledWhileEncodingReleasesEncodedValuescancels the result subscription while the second bind value is being encoded and checks that both encoded buffers are released. It fails without the change.New Public APIs
None.
Additional context
With Netty's allocator caches disabled, 10,000 statements cancelled from another thread while being subscribed left 379 buffers unreleased with one bind value each, and 4,679 with twenty, before the change; none after it.
mvn verify -DskipITspasses on Java 25. The change follows the formatting of the surrounding code.