Skip to content

Cache Pinecone Index connection in PineconeVectorStore#6589

Open
TimurRakhmatullin86 wants to merge 1 commit into
spring-projects:mainfrom
TimurRakhmatullin86:fix/pinecone-cache-index-connection
Open

Cache Pinecone Index connection in PineconeVectorStore#6589
TimurRakhmatullin86 wants to merge 1 commit into
spring-projects:mainfrom
TimurRakhmatullin86:fix/pinecone-cache-index-connection

Conversation

@TimurRakhmatullin86

Copy link
Copy Markdown
Contributor

PineconeVectorStore called Pinecone.getIndexConnection(indexName) on every add, delete, and similaritySearch operation. In the Pinecone Java client, getIndexConnection performs a blocking control-plane REST call (describeIndex) to resolve the index host on every invocation. Under bulk ingestion or query load this adds an extra HTTP round-trip of latency to each data-plane operation and runs into control-plane rate limits (HTTP 429).

The repeated call is pure overhead: the underlying gRPC connection is already cached in the client's static connectionsMap (computeIfAbsent), so the host resolved by every describeIndex call after the first one is discarded.

Changes:

  • Resolve the Index connection lazily once and reuse it across operations (volatile field with double-checked locking). If resolution fails, the field stays unset and the next operation retries.
  • The cached connection is intentionally never closed by the store: Index.close() closes the shared connection and removes it from the client's static connectionsMap, which would affect other consumers of the same index. The store did not close per-operation connections before this change either, so lifecycle behavior is unchanged.
  • Remove dead code in similaritySearch: a QueryRequest builder was constructed but never used (the query is issued via queryByVector), along with the now-unused io.pinecone.proto.QueryRequest import.
  • Add PineconeVectorStoreTests (no network) verifying the connection is resolved exactly once across add/delete/search and lazily on first use.

PineconeVectorStore called Pinecone.getIndexConnection(indexName) on every add,
delete and similaritySearch. In the Pinecone client that performs a blocking
control-plane describeIndex REST call on every invocation, adding a round trip of
latency per data-plane operation and running into control-plane rate limits (429).
The underlying gRPC connection is already cached in the client's static
connectionsMap, so the repeated host resolution is pure overhead.

Resolve the Index connection lazily once and reuse it (volatile field with
double-checked locking); it is intentionally never closed by the store since
Index.close() would remove the shared connection from the client's static map.
Also remove dead code in similaritySearch (an unused QueryRequest builder and its
import).

Signed-off-by: Timur Rakhmatullin <174210871+TimurRakhmatullin86@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants