Skip to content
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

partners[pinecone]: Prevent race condition in add_texts() method #28023

Closed

Conversation

orkhank
Copy link
Contributor

@orkhank orkhank commented Nov 11, 2024

Problem

When invoking the add_texts() method on the vector store, subsequent actions that depend on the existence of the newly added documents may result in errors or unexpected behavior. For example:

from langchain_pinecone import PineconeVectorStore

# Example code demonstrating the problem
vectore_store = PineconeVectorStore.from_texts(["Document 1", "Document 2"], ...)

# Immediately trying to retrieve the added documents
retrieved_docs = vector_store.similarity_search("Document 1")
# This may raise an error or return unexpected results if the documents are not yet indexed.

Solution

This pull request introduces a mechanism to block the addition of text to the index until the expected number of documents has been reached. The added code ensures that all insertions are completed only when the vector count in the index matches the anticipated document count.

Considerations

I have implemented this solution based on the assumption that no additional updates will occur on the index during this process. However, I am open to feedback regarding this interpretation of the problem and any alternative approaches that may be more effective.

Copy link

vercel bot commented Nov 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Nov 11, 2024 3:00pm

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Ɑ: vector store Related to vector store module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Nov 11, 2024
@efriis
Copy link
Member

efriis commented Nov 20, 2024

appreciate the thought! however, this is actually the same behavior as calling the pinecone api directly due to an eventual consistency guarantee, and we don't want to by-default block even longer.

I would prefer to document how folks can implement this loop themselves to overcome eventual consistency rather than merge this into the integration.

@efriis efriis closed this Nov 20, 2024
@orkhank
Copy link
Contributor Author

orkhank commented Nov 21, 2024

Yeah, that makes sense. Thanks for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature size:M This PR changes 30-99 lines, ignoring generated files. Ɑ: vector store Related to vector store module
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants