Skip to content

Fix CassandraVectorStore executor thread pool leak (GH #5931)#5952

Open
redinside-dev wants to merge 2 commits intospring-projects:mainfrom
redinside-dev:fix/5931-cassandra-vectorstore-executor-shutdown
Open

Fix CassandraVectorStore executor thread pool leak (GH #5931)#5952
redinside-dev wants to merge 2 commits intospring-projects:mainfrom
redinside-dev:fix/5931-cassandra-vectorstore-executor-shutdown

Conversation

@redinside-dev
Copy link
Copy Markdown

Summary

Fixes thread pool leak in CassandraVectorStore where the ExecutorService created in the constructor was never shut down in close().

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 the close() method, ensuring proper cleanup of the fixed-size thread pool alongside the session.

Changes

  • CassandraVectorStore.java: Added executor shutdown before session close in close() method
  • CassandraVectorStoreExecutorShutdownIT.java: New regression test that creates and closes multiple store instances, verifying no thread accumulation via ThreadMXBean

Testing

Test verifies thread count remains stable after creating/closing multiple CassandraVectorStore instances with fixedThreadPoolExecutorSize=8.

Closes #5931

anuragg-saxenaa and others added 2 commits April 23, 2026 17:11
…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>
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.

CassandraVectorStore does not close ExecutorService causing thread leak

2 participants