Fix CassandraVectorStore executor thread pool leak (GH #5931)#5952
Open
redinside-dev wants to merge 2 commits intospring-projects:mainfrom
Open
Fix CassandraVectorStore executor thread pool leak (GH #5931)#5952redinside-dev wants to merge 2 commits intospring-projects:mainfrom
redinside-dev wants to merge 2 commits intospring-projects:mainfrom
Conversation
…cts#5780) Fix stream mode toolCall information loss in tool calling loops (Issue spring-projects#5167) Fix issue spring-projects#5832: Validate all results in multi-result ChatResponses
…s#5931) Add executor.shutdown() to the close() method to properly shut down the fixed-size ExecutorService thread pool created in the constructor. Previously, every store.close() call left threads running, accumulating resource exhaustion in long-running applications. The fix follows a try-first pattern ensuring executor shutdown happens before session.close(), and handles the case where closeSessionOnClose may not be set. Added regression test CassandraVectorStoreExecutorShutdownIT that: - Creates and closes multiple CassandraVectorStore instances - Verifies no thread accumulation via ThreadMXBean thread count - Tests both normal close and session-close scenarios Signed-off-by: Redos OSS Bot <redos-oss@redinside.dev>
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.
Summary
Fixes thread pool leak in
CassandraVectorStorewhere theExecutorServicecreated in the constructor was never shut down inclose().The Problem
Every
store.close()call left threads running — they accumulate, never GC, causing resource exhaustion in long-running applications.The Fix
Added
executor.shutdown()to theclose()method, ensuring proper cleanup of the fixed-size thread pool alongside the session.Changes
close()methodThreadMXBeanTesting
Test verifies thread count remains stable after creating/closing multiple
CassandraVectorStoreinstances withfixedThreadPoolExecutorSize=8.Closes #5931