-
Notifications
You must be signed in to change notification settings - Fork 1.1k
JdbcMessageStore doesn't close database connections after streaming stored messages #3785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah... Looks like an omission on our side.
Has to be closed via Will fix shortly. Thank you! |
The problem is here
I wonder if there are more places like this... |
Well, we even mention that in docs: https://docs.spring.io/spring-integration/docs/current/reference/html/system-management.html#lazy-load-message-group
So, this is just a bug in the framework code by itself 😄 |
Fixes spring-projects#3785 * Fix `CollectionArgumentResolver` and `PayloadsArgumentResolver` to close the `Stream` of message after its usage * Rework `AbstractKeyValueMessageStore.removeMessagesFromGroup()` to iterate input collection of messages not its stream to avoid the mentioned problem **Cherry-pick to `5.5.x`**
* GH-3785: Close stream for persistent collection Fixes #3785 * Fix `CollectionArgumentResolver` and `PayloadsArgumentResolver` to close the `Stream` of message after its usage * Rework `AbstractKeyValueMessageStore.removeMessagesFromGroup()` to iterate input collection of messages not its stream to avoid the mentioned problem **Cherry-pick to `5.5.x`** * * Add `JdbcMessageStoreTests.testMessageGroupStreamNoConnectionPoolLeak()` to ensure that no leaks in the connection pool anymore. * Improve `MessageGroupStore.streamMessagesForGroup()` JavaDocs about requirements to close the `Stream` from persistent message store impls
* GH-3785: Close stream for persistent collection Fixes #3785 * Fix `CollectionArgumentResolver` and `PayloadsArgumentResolver` to close the `Stream` of message after its usage * Rework `AbstractKeyValueMessageStore.removeMessagesFromGroup()` to iterate input collection of messages not its stream to avoid the mentioned problem **Cherry-pick to `5.5.x`** * * Add `JdbcMessageStoreTests.testMessageGroupStreamNoConnectionPoolLeak()` to ensure that no leaks in the connection pool anymore. * Improve `MessageGroupStore.streamMessagesForGroup()` JavaDocs about requirements to close the `Stream` from persistent message store impls
In what version(s) of Spring Integration are you seeing this issue?
5.5.10
Describe the bug
Usage of
JdbcMessageStore
eventually leads to the database connection pool depletion as the connections are not getting properly closed after streaming the messages. After a while, the application stops functioning correctly, as the database connection pool never receives those connections back and treats them as active.This seems to happen on:
MessageGroupStoreReaper
instancegetMessages().stream()
The issue appears to be with the stream from
PersistentMessageGroup#streamMessages
not getting closed after the usage in certain cases.To Reproduce
Set up the application with a limited database connection pool, configure an aggregation flow with an instance of
JdbcMessageStore
and a scheduledMessageGroupStoreReaper
execution for that message store.Expected behavior
Internal usages of the message store should properly release database connections when
JdbcMessageStore
is utilized.If the current behavior of streaming on
MessageGroup#getMessages
is expected, the need for closing the stream should ideally be mentioned in the documentation.Sample
Sample application
The text was updated successfully, but these errors were encountered: